From: Shivam Garg Date: Sat, 16 Sep 2017 16:42:41 +0000 (+0900) Subject: Clean-duplicated-code-in-alc5658_configure X-Git-Tag: 1.1_Public_Release~188^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d65fba6783b46fd0725a5c1c6de6e3a82a4b7e69;p=rtos%2Ftinyara.git Clean-duplicated-code-in-alc5658_configure --- diff --git a/os/drivers/audio/alc5658.c b/os/drivers/audio/alc5658.c index 584aee0..c7da26a 100644 --- a/os/drivers/audio/alc5658.c +++ b/os/drivers/audio/alc5658.c @@ -547,8 +547,9 @@ static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct break; } break; /* Break for inner switch case */ - case AUDIO_TYPE_INPUT: { - audvdbg(" AUDIO_TYPE_INPUT:\n"); + case AUDIO_TYPE_INPUT: + case AUDIO_TYPE_OUTPUT: + audvdbg(" AUDIO_TYPE :%s\n", caps->ac_type == AUDIO_TYPE_INPUT ? "INPUT" : "OUTPUT"); /* Verify that all of the requested values are supported */ ret = -ERANGE; @@ -575,42 +576,13 @@ static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct /* Reconfigure the FLL to support the resulting number or channels, * bits per sample, and bitrate. */ - priv->inout = true; ret = OK; - } - break; - case AUDIO_TYPE_OUTPUT: { - audvdbg(" AUDIO_TYPE_OUTPUT:\n"); - /* Verify that all of the requested values are supported */ - - ret = -ERANGE; - if (caps->ac_channels != 1 && caps->ac_channels != 2) { - auddbg("ERROR: Unsupported number of channels: %d\n", caps->ac_channels); - break; - } - - if (caps->ac_controls.b[2] != 8 && caps->ac_controls.b[2] != 16) { - auddbg("ERROR: Unsupported bits per sample: %d\n", caps->ac_controls.b[2]); - break; + if (caps->ac_type == AUDIO_TYPE_INPUT) { + priv->inout = true; + } else { + priv->inout = false; } - - /* Save the current stream configuration */ - - priv->samprate = caps->ac_controls.hw[0]; - priv->nchannels = caps->ac_channels; - priv->bpsamp = caps->ac_controls.b[2]; - - audvdbg(" Number of channels: 0x%x\n", priv->nchannels); - audvdbg(" Sample rate: 0x%x\n", priv->samprate); - audvdbg(" Sample width: 0x%x\n", priv->bpsamp); - - /* Reconfigure the FLL to support the resulting number or channels, - * bits per sample, and bitrate. - */ - ret = OK; - priv->inout = false; - } - break; + break; case AUDIO_TYPE_PROCESSING: break;