/* Set higher or lower the codec volume level.  */
int32_t CS42L51_SetVolume(CS42L51_Object_t *pObj, uint32_t InputOutput, uint8_t Volume)
/* Set higher or lower the codec volume level.  */
int32_t CS42L51_SetVolume(CS42L51_Object_t *pObj, uint32_t InputOutput, uint8_t Volume)
{
  int32_t ret;
  uint8_t convertedvol;
  if (InputOutput != VOLUME_OUTPUT)
  {
    ret = CS42L51_ERROR;
  }
  else
  {
    convertedvol = VOLUME_CONVERT(Volume);
    ret = cs42l51_write_reg(&pObj->Ctx, CS42L51_AOUTA_VOL_CTRL, &convertedvol, 1);
    ret += cs42l51_write_reg(&pObj->Ctx, CS42L51_AOUTB_VOL_CTRL, &convertedvol, 1);
  }
  if (ret != CS42L51_OK)
  {
    ret = CS42L51_ERROR;
  }
  return ret;
}