diff options
Diffstat (limited to 'sound/pci/lx6464es/lx_core.c')
| -rw-r--r-- | sound/pci/lx6464es/lx_core.c | 130 |
1 files changed, 41 insertions, 89 deletions
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index d3f58a3d17fb..6f0843cfb3be 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -231,14 +231,14 @@ static void lx_message_dump(struct lx_rmh *rmh) u8 idx = rmh->cmd_idx; int i; - snd_printk(LXRMH "command %s\n", dsp_commands[idx].dcOpName); + pr_debug(LXRMH "command %s\n", dsp_commands[idx].dcOpName); for (i = 0; i != rmh->cmd_len; ++i) - snd_printk(LXRMH "\tcmd[%d] %08x\n", i, rmh->cmd[i]); + pr_debug(LXRMH "\tcmd[%d] %08x\n", i, rmh->cmd[i]); for (i = 0; i != rmh->stat_len; ++i) - snd_printk(LXRMH "\tstat[%d]: %08x\n", i, rmh->stat[i]); - snd_printk("\n"); + pr_debug(LXRMH "\tstat[%d]: %08x\n", i, rmh->stat[i]); + pr_debug("\n"); } #else static inline void lx_message_dump(struct lx_rmh *rmh) @@ -316,26 +316,25 @@ polling_successful: /* low-level dsp access */ int lx_dsp_get_version(struct lx6464es *chip, u32 *rdsp_version) { - u16 ret; + int ret; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG); ret = lx_message_send_atomic(chip, &chip->rmh); *rdsp_version = chip->rmh.stat[1]; - mutex_unlock(&chip->msg_lock); return ret; } int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq) { - u16 ret = 0; u32 freq_raw = 0; u32 freq = 0; u32 frequency = 0; + int ret; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG); ret = lx_message_send_atomic(chip, &chip->rmh); @@ -353,8 +352,6 @@ int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq) frequency = 48000; } - mutex_unlock(&chip->msg_lock); - *rfreq = frequency * chip->freq_ratio; return ret; @@ -381,23 +378,19 @@ int lx_dsp_get_mac(struct lx6464es *chip) int lx_dsp_set_granularity(struct lx6464es *chip, u32 gran) { - int ret; - - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_02_SET_GRANULARITY); chip->rmh.cmd[0] |= gran; - ret = lx_message_send_atomic(chip, &chip->rmh); - mutex_unlock(&chip->msg_lock); - return ret; + return lx_message_send_atomic(chip, &chip->rmh); } int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data) { int ret; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_04_GET_EVENT); chip->rmh.stat_len = 9; /* we don't necessarily need the full length */ @@ -407,7 +400,6 @@ int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data) if (!ret) memcpy(data, chip->rmh.stat, chip->rmh.stat_len * sizeof(u32)); - mutex_unlock(&chip->msg_lock); return ret; } @@ -423,14 +415,13 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_06_ALLOCATE_PIPE); chip->rmh.cmd[0] |= pipe_cmd; chip->rmh.cmd[0] |= channels; err = lx_message_send_atomic(chip, &chip->rmh); - mutex_unlock(&chip->msg_lock); if (err != 0) dev_err(chip->card->dev, "could not allocate pipe\n"); @@ -440,18 +431,14 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture, int lx_pipe_release(struct lx6464es *chip, u32 pipe, int is_capture) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_07_RELEASE_PIPE); chip->rmh.cmd[0] |= pipe_cmd; - err = lx_message_send_atomic(chip, &chip->rmh); - mutex_unlock(&chip->msg_lock); - - return err; + return lx_message_send_atomic(chip, &chip->rmh); } int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, @@ -468,7 +455,7 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, *r_needed = 0; *r_freed = 0; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_08_ASK_BUFFERS); chip->rmh.cmd[0] |= pipe_cmd; @@ -493,50 +480,40 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, dev_dbg(chip->card->dev, "CMD_08_ASK_BUFFERS: needed %d, freed %d\n", *r_needed, *r_freed); - for (i = 0; i < MAX_STREAM_BUFFER; ++i) { - for (i = 0; i != chip->rmh.stat_len; ++i) - dev_dbg(chip->card->dev, - " stat[%d]: %x, %x\n", i, - chip->rmh.stat[i], - chip->rmh.stat[i] & MASK_DATA_SIZE); + for (i = 0; i < MAX_STREAM_BUFFER && i < chip->rmh.stat_len; + ++i) { + dev_dbg(chip->card->dev, " stat[%d]: %x, %x\n", i, + chip->rmh.stat[i], + chip->rmh.stat[i] & MASK_DATA_SIZE); } } - mutex_unlock(&chip->msg_lock); return err; } int lx_pipe_stop(struct lx6464es *chip, u32 pipe, int is_capture) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_09_STOP_PIPE); chip->rmh.cmd[0] |= pipe_cmd; - err = lx_message_send_atomic(chip, &chip->rmh); - - mutex_unlock(&chip->msg_lock); - return err; + return lx_message_send_atomic(chip, &chip->rmh); } static int lx_pipe_toggle_state(struct lx6464es *chip, u32 pipe, int is_capture) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0B_TOGGLE_PIPE_STATE); chip->rmh.cmd[0] |= pipe_cmd; - err = lx_message_send_atomic(chip, &chip->rmh); - - mutex_unlock(&chip->msg_lock); - return err; + return lx_message_send_atomic(chip, &chip->rmh); } @@ -573,7 +550,7 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT); chip->rmh.cmd[0] |= pipe_cmd; @@ -590,7 +567,6 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture, + chip->rmh.stat[1]; /* lo part */ } - mutex_unlock(&chip->msg_lock); return err; } @@ -599,7 +575,7 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate) int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT); chip->rmh.cmd[0] |= pipe_cmd; @@ -611,7 +587,6 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate) else *rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F; - mutex_unlock(&chip->msg_lock); return err; } @@ -652,29 +627,24 @@ int lx_pipe_wait_for_idle(struct lx6464es *chip, u32 pipe, int is_capture) int lx_stream_set_state(struct lx6464es *chip, u32 pipe, int is_capture, enum stream_state_t state) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_13_SET_STREAM_STATE); chip->rmh.cmd[0] |= pipe_cmd; chip->rmh.cmd[0] |= state; - err = lx_message_send_atomic(chip, &chip->rmh); - mutex_unlock(&chip->msg_lock); - - return err; + return lx_message_send_atomic(chip, &chip->rmh); } int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime, u32 pipe, int is_capture) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); u32 channels = runtime->channels; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0C_DEF_STREAM); chip->rmh.cmd[0] |= pipe_cmd; @@ -689,10 +659,7 @@ int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime, chip->rmh.cmd[0] |= channels-1; - err = lx_message_send_atomic(chip, &chip->rmh); - mutex_unlock(&chip->msg_lock); - - return err; + return lx_message_send_atomic(chip, &chip->rmh); } int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture, @@ -701,7 +668,7 @@ int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT); chip->rmh.cmd[0] |= pipe_cmd; @@ -710,7 +677,6 @@ int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture, *rstate = (chip->rmh.stat[0] & SF_START) ? START_STATE : PAUSE_STATE; - mutex_unlock(&chip->msg_lock); return err; } @@ -720,7 +686,7 @@ int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT); chip->rmh.cmd[0] |= pipe_cmd; @@ -731,7 +697,6 @@ int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture, << 32) /* hi part */ + chip->rmh.stat[1]; /* lo part */ - mutex_unlock(&chip->msg_lock); return err; } @@ -743,7 +708,7 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0F_UPDATE_BUFFER); chip->rmh.cmd[0] |= pipe_cmd; @@ -764,7 +729,7 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture, if (err == 0) { *r_buffer_index = chip->rmh.stat[0]; - goto done; + return err; } if (err == EB_RBUFFERS_TABLE_OVERFLOW) @@ -779,8 +744,6 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture, dev_err(chip->card->dev, "lx_buffer_give EB_CMD_REFUSED\n"); - done: - mutex_unlock(&chip->msg_lock); return err; } @@ -790,7 +753,7 @@ int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture, int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER); chip->rmh.cmd[0] |= pipe_cmd; @@ -802,26 +765,21 @@ int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture, if (err == 0) *r_buffer_size = chip->rmh.stat[0] & MASK_DATA_SIZE; - mutex_unlock(&chip->msg_lock); return err; } int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture, u32 buffer_index) { - int err; u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER); chip->rmh.cmd[0] |= pipe_cmd; chip->rmh.cmd[0] |= buffer_index; - err = lx_message_send_atomic(chip, &chip->rmh); - - mutex_unlock(&chip->msg_lock); - return err; + return lx_message_send_atomic(chip, &chip->rmh); } @@ -832,11 +790,10 @@ int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture, * */ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute) { - int err; /* bit set to 1: channel muted */ u64 mute_mask = unmute ? 0 : 0xFFFFFFFFFFFFFFFFLLU; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); lx_message_init(&chip->rmh, CMD_0D_SET_MUTE); chip->rmh.cmd[0] |= PIPE_INFO_TO_CMD(is_capture, 0); @@ -848,10 +805,7 @@ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute) "mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1], chip->rmh.cmd[2]); - err = lx_message_send_atomic(chip, &chip->rmh); - - mutex_unlock(&chip->msg_lock); - return err; + return lx_message_send_atomic(chip, &chip->rmh); } static const u32 peak_map[] = { @@ -879,7 +833,7 @@ int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels, int err = 0; int i; - mutex_lock(&chip->msg_lock); + guard(mutex)(&chip->msg_lock); for (i = 0; i < channels; i += 4) { u32 s0, s1, s2, s3; @@ -904,7 +858,6 @@ int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels, r_levels += 4; } - mutex_unlock(&chip->msg_lock); return err; } @@ -1034,7 +987,7 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip, dev_dbg(chip->card->dev, "->lx_interrupt_request_new_buffer\n"); - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array); dev_dbg(chip->card->dev, @@ -1048,7 +1001,6 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip, buffer_index, (unsigned long)buf, period_bytes); lx_stream->frame_pos = next_pos; - mutex_unlock(&chip->lock); return err; } |
