snd_ps3.h 3.5 KB

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