From: bsvt Date: Fri, 15 Sep 2017 07:36:55 +0000 (-0700) Subject: Alc5658 code cleanup X-Git-Tag: 1.1_Public_Release~188^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b278448cb8c45e05e029a48f0a66f2886f10314;p=rtos%2Ftinyara.git Alc5658 code cleanup --- diff --git a/os/drivers/audio/alc5658.c b/os/drivers/audio/alc5658.c index 0e3a8a0..836590c 100644 --- a/os/drivers/audio/alc5658.c +++ b/os/drivers/audio/alc5658.c @@ -178,6 +178,22 @@ static uint16_t alc5658_modifyreg(FAR struct alc5658_dev_s *priv, uint16_t regad return alc5658_readreg(priv, regaddr); } +static void alc5658_setregs(struct alc5658_dev_s *priv) +{ + alc5658_writereg(priv, ALC5658_IN1_CTRL, (0 + 16) << 8); + alc5658_writereg(priv, ALC5658_HPOUT_MUTE, 0); + alc5658_writereg(priv, ALC5658_HPOUT_VLML, 0xd00); + alc5658_writereg(priv, ALC5658_HPOUT_VLMR, 0x700); +} + +static void alc5658_getregs(struct alc5658_dev_s *priv) +{ + audvdbg("MIC GAIN 0x%x\n", (uint32_t) alc5658_readreg(priv, ALC5658_IN1_CTRL)); + audvdbg("MUTE HPOUT MUTE %x\n", (uint32_t) alc5658_readreg(priv, ALC5658_HPOUT_MUTE)); + audvdbg("VOLL 0x%x\n", (uint32_t) alc5658_readreg(priv, ALC5658_HPOUT_VLML)); + audvdbg("VOLR 0x%x\n", (uint32_t) alc5658_readreg(priv, ALC5658_HPOUT_VLMR)); +} + /************************************************************************************ * Name: alc5658_exec_i2c_script * @@ -214,6 +230,7 @@ static void alc5658_takesem(sem_t *sem) } while (ret < 0); } + /************************************************************************************ * Name: alc5658_scalevolume * @@ -227,7 +244,7 @@ static inline uint16_t alc5658_scalevolume(uint16_t volume, b16_t scale) { return b16toi((b16_t) volume * scale); } -#endif +#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */ /************************************************************************************ * Name: alc5658_setvolume @@ -561,12 +578,6 @@ 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. */ -#if 0 - alc5658_set_i2s_datawidth(priv); - alc5658_set_i2s_samplerate(priv); - - alc5658_clock_analysis(&priv->dev, "AUDIO_TYPE_OUTPUT"); -#endif priv->inout = true; ret = OK; } @@ -598,12 +609,6 @@ 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. */ -#if 0 - alc5658_set_i2s_datawidth(priv); - alc5658_set_i2s_samplerate(priv); - - alc5658_clock_analysis(&priv->dev, "AUDIO_TYPE_OUTPUT"); -#endif ret = OK; priv->inout = false; } @@ -796,6 +801,10 @@ static void alc5658_rxtxcallback(FAR struct i2s_dev_s *dev, FAR struct ap_buffer break; } } + + /* Call upper callback, let it post msg to user q */ + priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK); + alc5658_givesem(&priv->devsem); } @@ -823,7 +832,6 @@ static int alc5658_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct a alc5658_givesem(&priv->devsem); return OK; } - if (priv->inout) /* record */ ret = I2S_RECEIVE(priv->i2s, apb, alc5658_rxtxcallback, priv, 0); else /* playback */ @@ -1149,8 +1157,6 @@ static void alc5658_hw_reset(FAR struct alc5658_dev_s *priv) /* Dump some information and return the device instance */ - alc5658_dump_registers(&priv->dev, "After configuration"); - alc5658_clock_analysis(&priv->dev, "After configuration"); } /**************************************************************************** diff --git a/os/drivers/audio/alc5658.h b/os/drivers/audio/alc5658.h index 16c6530..318b48f 100644 --- a/os/drivers/audio/alc5658.h +++ b/os/drivers/audio/alc5658.h @@ -21,7 +21,6 @@ /**************************************************************************** * Included Files ****************************************************************************/ - #include #include #include @@ -32,20 +31,21 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ - + #define ALC5658_DEFAULT_SAMPRATE 16000 #define ALC5658_DEFAULT_NCHANNELS 2 #define ALC5658_DEFAULT_BPSAMP 16 #define FAIL 0xFFFF +#define alc5658_givesem(s) sem_post(s) /* Commonly defined and redefined macros */ #ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif /**************************************************************************** @@ -118,8 +118,6 @@ static void alc5658_writereg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, u static void alc5658_takesem(sem_t *sem); static uint16_t alc5658_modifyreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, uint16_t set, uint16_t clear); -#define alc5658_givesem(s) sem_post(s) - #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME static inline uint16_t alc5658_scalevolume(uint16_t volume, b16_t scale); static void alc5658_setvolume(FAR struct alc5658_dev_s *priv, uint16_t volume, bool mute); @@ -128,7 +126,6 @@ static void alc5658_setvolume(FAR struct alc5658_dev_s *priv, uint16_t volume, b static void alc5658_setbass(FAR struct alc5658_dev_s *priv, uint8_t bass); static void alc5658_settreble(FAR struct alc5658_dev_s *priv, uint8_t treble); #endif - static void alc5658_set_i2s_datawidth(FAR struct alc5658_dev_s *priv); static void alc5658_set_i2s_samplerate(FAR struct alc5658_dev_s *priv); @@ -184,7 +181,6 @@ static void alc5658_interrupt_work(FAR void *arg); static int alc5658_interrupt(FAR const struct alc5658_lower_s *lower, FAR void *arg); #endif - /* Initialization */ static void alc5658_audio_output(FAR struct alc5658_dev_s *priv); static void alc5658_audio_input(FAR struct alc5658_dev_s *priv); @@ -196,6 +192,5 @@ static void alc5658_configure_ints(FAR struct alc5658_dev_s *priv); static void alc5658_hw_reset(FAR struct alc5658_dev_s *priv); uint16_t alc5658_readreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr); - #endif /* CONFIG_AUDIO */ #endif /* __DRIVERS_AUDIO_ALC5658_H */