sound/soc/codecs/peb2466.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/peb2466.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/peb2466.c
Extension
.c
Size
56187 bytes
Lines
2067
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct peb2466_lookup {
	u8 (*table)[4];
	unsigned int count;
};

#define PEB2466_TLV_SIZE ARRAY_SIZE(((unsigned int[]){TLV_DB_SCALE_ITEM(0, 0, 0)}))

struct peb2466_lkup_ctrl {
	int reg;
	unsigned int index;
	const struct peb2466_lookup *lookup;
	unsigned int tlv_array[PEB2466_TLV_SIZE];
};

struct peb2466 {
	struct spi_device *spi;
	struct clk *mclk;
	struct gpio_desc *reset_gpio;
	u8 spi_tx_buf[2 + 8]; /* Cannot use stack area for SPI (dma-safe memory) */
	u8 spi_rx_buf[2 + 8]; /* Cannot use stack area for SPI (dma-safe memory) */
	struct regmap *regmap;
	struct {
		struct peb2466_lookup ax_lookup;
		struct peb2466_lookup ar_lookup;
		struct peb2466_lkup_ctrl ax_lkup_ctrl;
		struct peb2466_lkup_ctrl ar_lkup_ctrl;
		unsigned int tg1_freq_item;
		unsigned int tg2_freq_item;
	} ch[PEB2466_NB_CHANNEL];
	int max_chan_playback;
	int max_chan_capture;
	struct {
		struct gpio_chip gpio_chip;
		struct mutex lock;
		struct {
			unsigned int xr0;
			unsigned int xr1;
			unsigned int xr2;
			unsigned int xr3;
		} cache;
	} gpio;
};

#define PEB2466_CMD_R	(1 << 5)
#define PEB2466_CMD_W	(0 << 5)

#define PEB2466_CMD_MASK 0x18
#define PEB2466_CMD_XOP  0x18  /* XOP is 0bxxx11xxx */
#define PEB2466_CMD_SOP  0x10  /* SOP is 0bxxx10xxx */
#define PEB2466_CMD_COP  0x00  /* COP is 0bxxx0xxxx, handle 0bxxx00xxx */
#define PEB2466_CMD_COP1 0x08  /* COP is 0bxxx0xxxx, handle 0bxxx01xxx */

#define PEB2466_MAKE_XOP(_lsel)      (PEB2466_CMD_XOP | (_lsel))
#define PEB2466_MAKE_SOP(_ad, _lsel) (PEB2466_CMD_SOP | ((_ad) << 6) | (_lsel))
#define PEB2466_MAKE_COP(_ad, _code) (PEB2466_CMD_COP | ((_ad) << 6) | (_code))

#define PEB2466_CR0(_ch)	PEB2466_MAKE_SOP(_ch, 0x0)
#define   PEB2466_CR0_TH		(1 << 7)
#define   PEB2466_CR0_IMR1		(1 << 6)
#define   PEB2466_CR0_FRX		(1 << 5)
#define   PEB2466_CR0_FRR		(1 << 4)
#define   PEB2466_CR0_AX		(1 << 3)
#define   PEB2466_CR0_AR		(1 << 2)
#define   PEB2466_CR0_THSEL_MASK	(0x3 << 0)
#define   PEB2466_CR0_THSEL(_set)	((_set) << 0)

#define PEB2466_CR1(_ch)	PEB2466_MAKE_SOP(_ch, 0x1)
#define   PEB2466_CR1_ETG2		(1 << 7)
#define   PEB2466_CR1_ETG1		(1 << 6)
#define   PEB2466_CR1_PTG2		(1 << 5)
#define   PEB2466_CR1_PTG1		(1 << 4)
#define   PEB2466_CR1_LAW_MASK		(1 << 3)
#define   PEB2466_CR1_LAW_ALAW		(0 << 3)
#define   PEB2466_CR1_LAW_MULAW		(1 << 3)
#define   PEB2466_CR1_PU		(1 << 0)

#define PEB2466_CR2(_ch)	PEB2466_MAKE_SOP(_ch, 0x2)
#define PEB2466_CR3(_ch)	PEB2466_MAKE_SOP(_ch, 0x3)
#define PEB2466_CR4(_ch)	PEB2466_MAKE_SOP(_ch, 0x4)
#define PEB2466_CR5(_ch)	PEB2466_MAKE_SOP(_ch, 0x5)

#define PEB2466_XR0		PEB2466_MAKE_XOP(0x0)
#define PEB2466_XR1		PEB2466_MAKE_XOP(0x1)
#define PEB2466_XR2		PEB2466_MAKE_XOP(0x2)
#define PEB2466_XR3		PEB2466_MAKE_XOP(0x3)
#define PEB2466_XR4		PEB2466_MAKE_XOP(0x4)
#define PEB2466_XR5		PEB2466_MAKE_XOP(0x5)
#define   PEB2466_XR5_MCLK_1536		(0x0 << 6)
#define   PEB2466_XR5_MCLK_2048		(0x1 << 6)
#define   PEB2466_XR5_MCLK_4096		(0x2 << 6)

Annotation

Implementation Notes