xref: /linux/sound/ppc/snd_ps3.h (revision c454fd4e888dc2b1423b6a65106a619e99a2deb4)
1*c454fd4eSMasakazu Mokuno /*
2*c454fd4eSMasakazu Mokuno  * Audio support for PS3
3*c454fd4eSMasakazu Mokuno  * Copyright (C) 2007 Sony Computer Entertainment Inc.
4*c454fd4eSMasakazu Mokuno  * All rights reserved.
5*c454fd4eSMasakazu Mokuno  * Copyright 2006, 2007 Sony Corporation
6*c454fd4eSMasakazu Mokuno  *
7*c454fd4eSMasakazu Mokuno  * This program is free software; you can redistribute it and/or modify
8*c454fd4eSMasakazu Mokuno  * it under the terms of the GNU General Public License
9*c454fd4eSMasakazu Mokuno  * as published by the Free Software Foundation; version 2 of the Licence.
10*c454fd4eSMasakazu Mokuno  *
11*c454fd4eSMasakazu Mokuno  * This program is distributed in the hope that it will be useful,
12*c454fd4eSMasakazu Mokuno  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c454fd4eSMasakazu Mokuno  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*c454fd4eSMasakazu Mokuno  * GNU General Public License for more details.
15*c454fd4eSMasakazu Mokuno  *
16*c454fd4eSMasakazu Mokuno  * You should have received a copy of the GNU General Public License
17*c454fd4eSMasakazu Mokuno  * along with this program; if not, write to the Free Software
18*c454fd4eSMasakazu Mokuno  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19*c454fd4eSMasakazu Mokuno  */
20*c454fd4eSMasakazu Mokuno 
21*c454fd4eSMasakazu Mokuno #if !defined(_SND_PS3_H_)
22*c454fd4eSMasakazu Mokuno #define _SND_PS3_H_
23*c454fd4eSMasakazu Mokuno 
24*c454fd4eSMasakazu Mokuno #include <linux/irqreturn.h>
25*c454fd4eSMasakazu Mokuno 
26*c454fd4eSMasakazu Mokuno #define SND_PS3_DRIVER_NAME "snd_ps3"
27*c454fd4eSMasakazu Mokuno 
28*c454fd4eSMasakazu Mokuno enum snd_ps3_out_channel {
29*c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SPDIF_0,
30*c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SPDIF_1,
31*c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_SERIAL_0,
32*c454fd4eSMasakazu Mokuno 	SND_PS3_OUT_DEVS
33*c454fd4eSMasakazu Mokuno };
34*c454fd4eSMasakazu Mokuno 
35*c454fd4eSMasakazu Mokuno enum snd_ps3_dma_filltype {
36*c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_FIRSTFILL,
37*c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_RUNNING,
38*c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL,
39*c454fd4eSMasakazu Mokuno 	SND_PS3_DMA_FILLTYPE_SILENT_RUNNING
40*c454fd4eSMasakazu Mokuno };
41*c454fd4eSMasakazu Mokuno 
42*c454fd4eSMasakazu Mokuno enum snd_ps3_ch {
43*c454fd4eSMasakazu Mokuno 	SND_PS3_CH_L = 0,
44*c454fd4eSMasakazu Mokuno 	SND_PS3_CH_R = 1,
45*c454fd4eSMasakazu Mokuno 	SND_PS3_CH_MAX = 2
46*c454fd4eSMasakazu Mokuno };
47*c454fd4eSMasakazu Mokuno 
48*c454fd4eSMasakazu Mokuno struct snd_ps3_avsetting_info {
49*c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_ch;     /* fixed */
50*c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_rate;
51*c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_width;
52*c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_format; /* fixed */
53*c454fd4eSMasakazu Mokuno 	uint32_t avs_audio_source; /* fixed */
54*c454fd4eSMasakazu Mokuno };
55*c454fd4eSMasakazu Mokuno /*
56*c454fd4eSMasakazu Mokuno  * PS3 audio 'card' instance
57*c454fd4eSMasakazu Mokuno  * there should be only ONE hardware.
58*c454fd4eSMasakazu Mokuno  */
59*c454fd4eSMasakazu Mokuno struct snd_ps3_card_info {
60*c454fd4eSMasakazu Mokuno 	struct ps3_system_bus_device *ps3_dev;
61*c454fd4eSMasakazu Mokuno 	struct snd_card *card;
62*c454fd4eSMasakazu Mokuno 
63*c454fd4eSMasakazu Mokuno 	struct snd_pcm *pcm;
64*c454fd4eSMasakazu Mokuno 	struct snd_pcm_substream *substream;
65*c454fd4eSMasakazu Mokuno 
66*c454fd4eSMasakazu Mokuno 	/* hvc info */
67*c454fd4eSMasakazu Mokuno 	u64 audio_lpar_addr;
68*c454fd4eSMasakazu Mokuno 	u64 audio_lpar_size;
69*c454fd4eSMasakazu Mokuno 
70*c454fd4eSMasakazu Mokuno 	/* registers */
71*c454fd4eSMasakazu Mokuno 	void __iomem *mapped_mmio_vaddr;
72*c454fd4eSMasakazu Mokuno 
73*c454fd4eSMasakazu Mokuno 	/* irq */
74*c454fd4eSMasakazu Mokuno 	u64 audio_irq_outlet;
75*c454fd4eSMasakazu Mokuno 	unsigned int irq_no;
76*c454fd4eSMasakazu Mokuno 
77*c454fd4eSMasakazu Mokuno 	/* remember avsetting */
78*c454fd4eSMasakazu Mokuno 	struct snd_ps3_avsetting_info avs;
79*c454fd4eSMasakazu Mokuno 
80*c454fd4eSMasakazu Mokuno 	/* dma buffer management */
81*c454fd4eSMasakazu Mokuno 	spinlock_t dma_lock;
82*c454fd4eSMasakazu Mokuno 		/* dma_lock start */
83*c454fd4eSMasakazu Mokuno 		void * dma_start_vaddr[2]; /* 0 for L, 1 for R */
84*c454fd4eSMasakazu Mokuno 		dma_addr_t dma_start_bus_addr[2];
85*c454fd4eSMasakazu Mokuno 		size_t dma_buffer_size;
86*c454fd4eSMasakazu Mokuno 		void * dma_last_transfer_vaddr[2];
87*c454fd4eSMasakazu Mokuno 		void * dma_next_transfer_vaddr[2];
88*c454fd4eSMasakazu Mokuno 		int    silent;
89*c454fd4eSMasakazu Mokuno 		/* dma_lock end */
90*c454fd4eSMasakazu Mokuno 
91*c454fd4eSMasakazu Mokuno 	int running;
92*c454fd4eSMasakazu Mokuno 
93*c454fd4eSMasakazu Mokuno 	/* null buffer */
94*c454fd4eSMasakazu Mokuno 	void *null_buffer_start_vaddr;
95*c454fd4eSMasakazu Mokuno 	dma_addr_t null_buffer_start_dma_addr;
96*c454fd4eSMasakazu Mokuno 
97*c454fd4eSMasakazu Mokuno 	/* start delay */
98*c454fd4eSMasakazu Mokuno 	unsigned int start_delay;
99*c454fd4eSMasakazu Mokuno 
100*c454fd4eSMasakazu Mokuno };
101*c454fd4eSMasakazu Mokuno 
102*c454fd4eSMasakazu Mokuno 
103*c454fd4eSMasakazu Mokuno /* PS3 audio DMAC block size in bytes */
104*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_DMAC_BLOCK_SIZE (128)
105*c454fd4eSMasakazu Mokuno /* one stage (stereo)  of audio FIFO in bytes */
106*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_STAGE_SIZE (256)
107*c454fd4eSMasakazu Mokuno /* how many stages the fifo have */
108*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_STAGE_COUNT (8)
109*c454fd4eSMasakazu Mokuno /* fifo size 128 bytes * 8 stages * stereo (2ch) */
110*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_FIFO_SIZE \
111*c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_FIFO_STAGE_SIZE * PS3_AUDIO_FIFO_STAGE_COUNT)
112*c454fd4eSMasakazu Mokuno 
113*c454fd4eSMasakazu Mokuno /* PS3 audio DMAC max block count in one dma shot = 128 (0x80) blocks*/
114*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_DMAC_MAX_BLOCKS  (PS3_AUDIO_DMASIZE_BLOCKS_MASK + 1)
115*c454fd4eSMasakazu Mokuno 
116*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NORMAL_DMA_START_CH (0)
117*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NORMAL_DMA_COUNT    (8)
118*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NULL_DMA_START_CH \
119*c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_NORMAL_DMA_START_CH + PS3_AUDIO_NORMAL_DMA_COUNT)
120*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_NULL_DMA_COUNT      (2)
121*c454fd4eSMasakazu Mokuno 
122*c454fd4eSMasakazu Mokuno #define SND_PS3_MAX_VOL (0x0F)
123*c454fd4eSMasakazu Mokuno #define SND_PS3_MIN_VOL (0x00)
124*c454fd4eSMasakazu Mokuno #define SND_PS3_MIN_ATT SND_PS3_MIN_VOL
125*c454fd4eSMasakazu Mokuno #define SND_PS3_MAX_ATT SND_PS3_MAX_VOL
126*c454fd4eSMasakazu Mokuno 
127*c454fd4eSMasakazu Mokuno #define SND_PS3_PCM_PREALLOC_SIZE \
128*c454fd4eSMasakazu Mokuno 	(PS3_AUDIO_DMAC_BLOCK_SIZE * PS3_AUDIO_DMAC_MAX_BLOCKS * 4)
129*c454fd4eSMasakazu Mokuno 
130*c454fd4eSMasakazu Mokuno #define SND_PS3_DMA_REGION_SIZE \
131*c454fd4eSMasakazu Mokuno 	(SND_PS3_PCM_PREALLOC_SIZE + PAGE_SIZE)
132*c454fd4eSMasakazu Mokuno 
133*c454fd4eSMasakazu Mokuno #define PS3_AUDIO_IOID       (1UL)
134*c454fd4eSMasakazu Mokuno 
135*c454fd4eSMasakazu Mokuno #endif /* _SND_PS3_H_ */
136