xref: /linux/sound/ppc/snd_ps3.h (revision e26441b693e1e332db1fd27846e9bb7466e0c35c)
1*e26441b6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2c454fd4eSMasakazu Mokuno /*
3c454fd4eSMasakazu Mokuno  * Audio support for PS3
4c454fd4eSMasakazu Mokuno  * Copyright (C) 2007 Sony Computer Entertainment Inc.
5c454fd4eSMasakazu Mokuno  * All rights reserved.
6c454fd4eSMasakazu Mokuno  * Copyright 2006, 2007 Sony Corporation
7c454fd4eSMasakazu Mokuno  */
8c454fd4eSMasakazu Mokuno 
9c454fd4eSMasakazu Mokuno #if !defined(_SND_PS3_H_)
10c454fd4eSMasakazu Mokuno #define _SND_PS3_H_
11c454fd4eSMasakazu Mokuno 
12c454fd4eSMasakazu Mokuno #include <linux/irqreturn.h>
13c454fd4eSMasakazu Mokuno 
14c454fd4eSMasakazu Mokuno #define SND_PS3_DRIVER_NAME "snd_ps3"
15c454fd4eSMasakazu Mokuno 
16c454fd4eSMasakazu Mokuno enum snd_ps3_out_channel {
17c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SPDIF_0,
18c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SPDIF_1,
19c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SERIAL_0,
20c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_DEVS
21c454fd4eSMasakazu Mokuno };
22c454fd4eSMasakazu Mokuno 
23c454fd4eSMasakazu Mokuno enum snd_ps3_dma_filltype {
24c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_FIRSTFILL,
25c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_RUNNING,
26c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL,
27c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_SILENT_RUNNING
28c454fd4eSMasakazu Mokuno };
29c454fd4eSMasakazu Mokuno 
30c454fd4eSMasakazu Mokuno enum snd_ps3_ch {
31c454fd4eSMasakazu Mokuno 	SND_PS3_CH_L = 0,
32c454fd4eSMasakazu Mokuno 	SND_PS3_CH_R = 1,
33c454fd4eSMasakazu Mokuno 	SND_PS3_CH_MAX = 2
34c454fd4eSMasakazu Mokuno };
35c454fd4eSMasakazu Mokuno 
36c454fd4eSMasakazu Mokuno struct snd_ps3_avsetting_info {
37c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_ch;     /* fixed */
38c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_rate;
39c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_width;
40c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_format; /* fixed */
41c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_source; /* fixed */
421ee2a322STakashi Iwai 	unsigned char avs_cs_info[8];
43c454fd4eSMasakazu Mokuno };
44c454fd4eSMasakazu Mokuno /*
45c454fd4eSMasakazu Mokuno  * PS3 audio 'card' instance
46c454fd4eSMasakazu Mokuno  * there should be only ONE hardware.
47c454fd4eSMasakazu Mokuno  */
48c454fd4eSMasakazu Mokuno struct snd_ps3_card_info {
49c454fd4eSMasakazu Mokuno 	struct ps3_system_bus_device *ps3_dev;
50c454fd4eSMasakazu Mokuno 	struct snd_card *card;
51c454fd4eSMasakazu Mokuno 
52c454fd4eSMasakazu Mokuno 	struct snd_pcm *pcm;
53c454fd4eSMasakazu Mokuno 	struct snd_pcm_substream *substream;
54c454fd4eSMasakazu Mokuno 
55c454fd4eSMasakazu Mokuno 	/* hvc info */
56c454fd4eSMasakazu Mokuno 	u64 audio_lpar_addr;
57c454fd4eSMasakazu Mokuno 	u64 audio_lpar_size;
58c454fd4eSMasakazu Mokuno 
59c454fd4eSMasakazu Mokuno 	/* registers */
60c454fd4eSMasakazu Mokuno 	void __iomem *mapped_mmio_vaddr;
61c454fd4eSMasakazu Mokuno 
62c454fd4eSMasakazu Mokuno 	/* irq */
63c454fd4eSMasakazu Mokuno 	u64 audio_irq_outlet;
64c454fd4eSMasakazu Mokuno 	unsigned int irq_no;
65c454fd4eSMasakazu Mokuno 
66c454fd4eSMasakazu Mokuno 	/* remember avsetting */
67c454fd4eSMasakazu Mokuno 	struct snd_ps3_avsetting_info avs;
68c454fd4eSMasakazu Mokuno 
69c454fd4eSMasakazu Mokuno 	/* dma buffer management */
70c454fd4eSMasakazu Mokuno 	spinlock_t dma_lock;
71c454fd4eSMasakazu Mokuno 		/* dma_lock start */
72c454fd4eSMasakazu Mokuno 		void * dma_start_vaddr[2]; /* 0 for L, 1 for R */
73c454fd4eSMasakazu Mokuno 		dma_addr_t dma_start_bus_addr[2];
74c454fd4eSMasakazu Mokuno 		size_t dma_buffer_size;
75c454fd4eSMasakazu Mokuno 		void * dma_last_transfer_vaddr[2];
76c454fd4eSMasakazu Mokuno 		void * dma_next_transfer_vaddr[2];
77c454fd4eSMasakazu Mokuno 		int    silent;
78c454fd4eSMasakazu Mokuno 		/* dma_lock end */
79c454fd4eSMasakazu Mokuno 
80c454fd4eSMasakazu Mokuno 	int running;
81c454fd4eSMasakazu Mokuno 
82c454fd4eSMasakazu Mokuno 	/* null buffer */
83c454fd4eSMasakazu Mokuno 	void *null_buffer_start_vaddr;
84c454fd4eSMasakazu Mokuno 	dma_addr_t null_buffer_start_dma_addr;
85c454fd4eSMasakazu Mokuno 
86c454fd4eSMasakazu Mokuno 	/* start delay */
87c454fd4eSMasakazu Mokuno 	unsigned int start_delay;
88c454fd4eSMasakazu Mokuno 
89c454fd4eSMasakazu Mokuno };
90c454fd4eSMasakazu Mokuno 
91c454fd4eSMasakazu Mokuno 
92c454fd4eSMasakazu Mokuno /* PS3 audio DMAC block size in bytes */
93c454fd4eSMasakazu Mokuno #define PS3_AUDIO_DMAC_BLOCK_SIZE (128)
94c454fd4eSMasakazu Mokuno /* one stage (stereo)  of audio FIFO in bytes */
95c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_STAGE_SIZE (256)
96c454fd4eSMasakazu Mokuno /* how many stages the fifo have */
97c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_STAGE_COUNT (8)
98c454fd4eSMasakazu Mokuno /* fifo size 128 bytes * 8 stages * stereo (2ch) */
99c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_SIZE \
100c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_FIFO_STAGE_SIZE * PS3_AUDIO_FIFO_STAGE_COUNT)
101c454fd4eSMasakazu Mokuno 
102c454fd4eSMasakazu Mokuno /* PS3 audio DMAC max block count in one dma shot = 128 (0x80) blocks*/
103c454fd4eSMasakazu Mokuno #define PS3_AUDIO_DMAC_MAX_BLOCKS  (PS3_AUDIO_DMASIZE_BLOCKS_MASK + 1)
104c454fd4eSMasakazu Mokuno 
105c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NORMAL_DMA_START_CH (0)
106c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NORMAL_DMA_COUNT    (8)
107c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NULL_DMA_START_CH \
108c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_NORMAL_DMA_START_CH + PS3_AUDIO_NORMAL_DMA_COUNT)
109c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NULL_DMA_COUNT      (2)
110c454fd4eSMasakazu Mokuno 
111c454fd4eSMasakazu Mokuno #define SND_PS3_MAX_VOL (0x0F)
112c454fd4eSMasakazu Mokuno #define SND_PS3_MIN_VOL (0x00)
113c454fd4eSMasakazu Mokuno #define SND_PS3_MIN_ATT SND_PS3_MIN_VOL
114c454fd4eSMasakazu Mokuno #define SND_PS3_MAX_ATT SND_PS3_MAX_VOL
115c454fd4eSMasakazu Mokuno 
116c454fd4eSMasakazu Mokuno #define SND_PS3_PCM_PREALLOC_SIZE \
117c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_DMAC_BLOCK_SIZE * PS3_AUDIO_DMAC_MAX_BLOCKS * 4)
118c454fd4eSMasakazu Mokuno 
119c454fd4eSMasakazu Mokuno #define SND_PS3_DMA_REGION_SIZE \
120c454fd4eSMasakazu Mokuno 	(SND_PS3_PCM_PREALLOC_SIZE + PAGE_SIZE)
121c454fd4eSMasakazu Mokuno 
122c454fd4eSMasakazu Mokuno #define PS3_AUDIO_IOID       (1UL)
123c454fd4eSMasakazu Mokuno 
124c454fd4eSMasakazu Mokuno #endif /* _SND_PS3_H_ */
125