Added CODEC headset detection/selction reg and bit defines.

This commit is contained in:
profi200 2021-11-05 17:53:41 +01:00
parent be6ef91834
commit 83215f5417
No known key found for this signature in database
GPG Key ID: 17B42AE5911139F3
3 changed files with 17 additions and 5 deletions

View File

@ -232,7 +232,7 @@ enum
// 50-66 reserved?
CDC_REG_100_67 = 100u<<8 | 67u,
CDC_REG_100_68 = 100u<<8 | 68u,
CDC_REG_100_69 = 100u<<8 | 69u,
CDC_REG_HEADSET_SEL = 100u<<8 | 69u,
// 70-116 reserved?
CDC_REG_100_117 = 100u<<8 | 117u,
CDC_REG_100_118 = 100u<<8 | 118u,
@ -307,3 +307,15 @@ enum
// 4 reserved?
CDC_REG_TWL_MODE = 255<<8 | 5u
};
// ----------------------------------------------------------------------------------
// CDC_REG_HEADSET_SEL (page 100 (0x64), reg 69 (0x45))
#define HEADSET_SEL_HP_SHIFT (4u)
#define HEADSET_SEL_SP (0u) // Force speaker output.
#define HEADSET_SEL_HP (1u<<HEADSET_SEL_HP_SHIFT) // Force headphone output.
#define HEADSET_SEL_HP_EN (1u<<5) // Enable headphone override.
#define HEADSET_SEL_MIC_SHIFT (6u)
#define HEADSET_SEL_INT_MIC (0u) // Force internal microphone input.
#define HEADSET_SEL_EXT_MIC (1u<<HEADSET_SEL_MIC_SHIFT) // Force external microphone input.
#define HEADSET_SEL_MIC_EN (1u<<7) // Enable microphone override.

View File

@ -432,8 +432,8 @@ static void headsetInit(void)
{
// Headset detection stuff.
GPIO_config(GPIO_2_HEADPH_JACK, GPIO_IRQ_ENABLE | GPIO_EDGE_RISING | GPIO_INPUT); // Headphone jack IRQ.
//maskReg(CDC_REG_100_69, GPIO_read(GPIO_2_HEADPH_JACK)<<4 | 1u<<5, 0x30); // GPIO bitmask 8.
maskReg(CDC_REG_100_69, 0, 0x30); // With automatic output switching.
//maskReg(CDC_REG_HEADSET_SEL, GPIO_read(GPIO_2_HEADPH_JACK)<<HEADSET_SEL_HP_SHIFT | HEADSET_SEL_HP_EN, 0x30); // GPIO bitmask 8.
maskReg(CDC_REG_HEADSET_SEL, 0, 0x30); // With automatic output switching.
maskReg(CDC_REG_100_67, 0, 0x80); // TODO: Can we remove this?
maskReg(CDC_REG_100_67, 0x80, 0x80);
}

View File

@ -16,12 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fs.h"
#include "drivers/gfx.h"
#include "arm11/console.h"
#include "arm11/drivers/codec.h"
#include "fs.h"
#include "arm11/open_agb_firm.h"
#include "arm11/drivers/hid.h"
#include "arm11/drivers/codec.h"
#include "arm11/power.h"