Lines Matching refs:compr
151 struct wm_adsp_compr *compr; member
1190 static inline int wm_adsp_compr_attached(struct wm_adsp_compr *compr) in wm_adsp_compr_attached() argument
1192 return compr->buf != NULL; in wm_adsp_compr_attached()
1195 static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) in wm_adsp_compr_attach() argument
1199 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
1202 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
1203 if (!tmp->name || !strcmp(compr->name, tmp->name)) { in wm_adsp_compr_attach()
1212 compr->buf = buf; in wm_adsp_compr_attach()
1213 buf->compr = compr; in wm_adsp_compr_attach()
1218 static void wm_adsp_compr_detach(struct wm_adsp_compr *compr) in wm_adsp_compr_detach() argument
1220 if (!compr) in wm_adsp_compr_detach()
1224 if (compr->stream) in wm_adsp_compr_detach()
1225 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_detach()
1227 if (wm_adsp_compr_attached(compr)) { in wm_adsp_compr_detach()
1228 compr->buf->compr = NULL; in wm_adsp_compr_detach()
1229 compr->buf = NULL; in wm_adsp_compr_detach()
1235 struct wm_adsp_compr *compr, *tmp; in wm_adsp_compr_open() local
1264 compr = kzalloc(sizeof(*compr), GFP_KERNEL); in wm_adsp_compr_open()
1265 if (!compr) { in wm_adsp_compr_open()
1270 compr->dsp = dsp; in wm_adsp_compr_open()
1271 compr->stream = stream; in wm_adsp_compr_open()
1272 compr->name = asoc_rtd_to_codec(rtd, 0)->name; in wm_adsp_compr_open()
1274 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
1276 stream->runtime->private_data = compr; in wm_adsp_compr_open()
1288 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_free() local
1289 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free()
1293 wm_adsp_compr_detach(compr); in wm_adsp_compr_free()
1294 list_del(&compr->list); in wm_adsp_compr_free()
1296 kfree(compr->raw_buf); in wm_adsp_compr_free()
1297 kfree(compr); in wm_adsp_compr_free()
1308 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_check_params() local
1309 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params()
1319 compr_err(compr, "Invalid buffer fragsize=%d fragments=%d\n", in wm_adsp_compr_check_params()
1349 compr_err(compr, "Invalid params id=%u ch=%u,%u rate=%u fmt=%u\n", in wm_adsp_compr_check_params()
1355 static inline unsigned int wm_adsp_compr_frag_words(struct wm_adsp_compr *compr) in wm_adsp_compr_frag_words() argument
1357 return compr->size.fragment_size / CS_DSP_DATA_WORD_SIZE; in wm_adsp_compr_frag_words()
1364 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_set_params() local
1372 compr->size = params->buffer; in wm_adsp_compr_set_params()
1374 compr_dbg(compr, "fragment_size=%d fragments=%d\n", in wm_adsp_compr_set_params()
1375 compr->size.fragment_size, compr->size.fragments); in wm_adsp_compr_set_params()
1377 size = wm_adsp_compr_frag_words(compr) * sizeof(*compr->raw_buf); in wm_adsp_compr_set_params()
1378 compr->raw_buf = kmalloc(size, GFP_DMA | GFP_KERNEL); in wm_adsp_compr_set_params()
1379 if (!compr->raw_buf) in wm_adsp_compr_set_params()
1382 compr->sample_rate = params->codec.sample_rate; in wm_adsp_compr_set_params()
1392 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_get_caps() local
1393 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
1672 wm_adsp_compr_detach(buf->compr); in wm_adsp_buffer_free()
1703 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_trigger() local
1704 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger()
1707 compr_dbg(compr, "Trigger: %d\n", cmd); in wm_adsp_compr_trigger()
1713 if (!wm_adsp_compr_attached(compr)) { in wm_adsp_compr_trigger()
1714 ret = wm_adsp_compr_attach(compr); in wm_adsp_compr_trigger()
1716 compr_err(compr, "Failed to link buffer and stream: %d\n", in wm_adsp_compr_trigger()
1722 ret = wm_adsp_buffer_get_error(compr->buf); in wm_adsp_compr_trigger()
1727 ret = wm_adsp_buffer_write(compr->buf, in wm_adsp_compr_trigger()
1729 wm_adsp_compr_frag_words(compr)); in wm_adsp_compr_trigger()
1731 compr_err(compr, "Failed to set high water mark: %d\n", in wm_adsp_compr_trigger()
1737 if (wm_adsp_compr_attached(compr)) in wm_adsp_compr_trigger()
1738 wm_adsp_buffer_clear(compr->buf); in wm_adsp_compr_trigger()
1804 struct wm_adsp_compr *compr; in wm_adsp_compr_handle_irq() local
1817 compr = buf->compr; in wm_adsp_compr_handle_irq()
1840 if (compr && compr->stream) in wm_adsp_compr_handle_irq()
1841 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_handle_irq()
1868 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_pointer() local
1869 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer()
1873 compr_dbg(compr, "Pointer request\n"); in wm_adsp_compr_pointer()
1877 buf = compr->buf; in wm_adsp_compr_pointer()
1885 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
1888 compr_err(compr, "Error reading avail: %d\n", ret); in wm_adsp_compr_pointer()
1896 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
1907 compr_err(compr, "Failed to re-enable buffer IRQ: %d\n", in wm_adsp_compr_pointer()
1914 tstamp->copied_total = compr->copied_total; in wm_adsp_compr_pointer()
1916 tstamp->sampling_rate = compr->sample_rate; in wm_adsp_compr_pointer()
1925 static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target) in wm_adsp_buffer_capture_block() argument
1927 struct wm_adsp_compr_buf *buf = compr->buf; in wm_adsp_buffer_capture_block()
1944 max_read = wm_adsp_compr_frag_words(compr); in wm_adsp_buffer_capture_block()
1958 nwords, (__be32 *)compr->raw_buf); in wm_adsp_buffer_capture_block()
1962 cs_dsp_remove_padding(compr->raw_buf, nwords); in wm_adsp_buffer_capture_block()
1980 static int wm_adsp_compr_read(struct wm_adsp_compr *compr, in wm_adsp_compr_read() argument
1983 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read()
1987 compr_dbg(compr, "Requested read of %zu bytes\n", count); in wm_adsp_compr_read()
1989 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
1990 snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN); in wm_adsp_compr_read()
1997 nwords = wm_adsp_buffer_capture_block(compr, count); in wm_adsp_compr_read()
1999 compr_err(compr, "Failed to capture block: %d\n", in wm_adsp_compr_read()
2006 compr_dbg(compr, "Read %d bytes\n", nbytes); in wm_adsp_compr_read()
2008 if (copy_to_user(buf + ntotal, compr->raw_buf, nbytes)) { in wm_adsp_compr_read()
2009 compr_err(compr, "Failed to copy data to user: %d, %d\n", in wm_adsp_compr_read()
2018 compr->copied_total += ntotal; in wm_adsp_compr_read()
2027 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_copy() local
2028 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy()
2034 ret = wm_adsp_compr_read(compr, buf, count); in wm_adsp_compr_copy()
2047 struct wm_adsp_compr *compr; in wm_adsp_fatal_error() local
2051 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
2052 if (compr->stream) in wm_adsp_fatal_error()
2053 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_fatal_error()