snd_ps3.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. unsigned char avs_cs_info[8];
  48. };
  49. /*
  50. * PS3 audio 'card' instance
  51. * there should be only ONE hardware.
  52. */
  53. struct snd_ps3_card_info {
  54. struct ps3_system_bus_device *ps3_dev;
  55. struct snd_card *card;
  56. struct snd_pcm *pcm;
  57. struct snd_pcm_substream *substream;
  58. /* hvc info */
  59. u64 audio_lpar_addr;
  60. u64 audio_lpar_size;
  61. /* registers */
  62. void __iomem *mapped_mmio_vaddr;
  63. /* irq */
  64. u64 audio_irq_outlet;
  65. unsigned int irq_no;
  66. /* remember avsetting */
  67. struct snd_ps3_avsetting_info avs;
  68. /* dma buffer management */
  69. spinlock_t dma_lock;
  70. /* dma_lock start */
  71. void * dma_start_vaddr[2]; /* 0 for L, 1 for R */
  72. dma_addr_t dma_start_bus_addr[2];
  73. size_t dma_buffer_size;
  74. void * dma_last_transfer_vaddr[2];
  75. void * dma_next_transfer_vaddr[2];
  76. int silent;
  77. /* dma_lock end */
  78. int running;
  79. /* null buffer */
  80. void *null_buffer_start_vaddr;
  81. dma_addr_t null_buffer_start_dma_addr;
  82. /* start delay */
  83. unsigned int start_delay;
  84. };
  85. /* PS3 audio DMAC block size in bytes */
  86. #define PS3_AUDIO_DMAC_BLOCK_SIZE (128)
  87. /* one stage (stereo) of audio FIFO in bytes */
  88. #define PS3_AUDIO_FIFO_STAGE_SIZE (256)
  89. /* how many stages the fifo have */
  90. #define PS3_AUDIO_FIFO_STAGE_COUNT (8)
  91. /* fifo size 128 bytes * 8 stages * stereo (2ch) */
  92. #define PS3_AUDIO_FIFO_SIZE \
  93. (PS3_AUDIO_FIFO_STAGE_SIZE * PS3_AUDIO_FIFO_STAGE_COUNT)
  94. /* PS3 audio DMAC max block count in one dma shot = 128 (0x80) blocks*/
  95. #define PS3_AUDIO_DMAC_MAX_BLOCKS (PS3_AUDIO_DMASIZE_BLOCKS_MASK + 1)
  96. #define PS3_AUDIO_NORMAL_DMA_START_CH (0)
  97. #define PS3_AUDIO_NORMAL_DMA_COUNT (8)
  98. #define PS3_AUDIO_NULL_DMA_START_CH \
  99. (PS3_AUDIO_NORMAL_DMA_START_CH + PS3_AUDIO_NORMAL_DMA_COUNT)
  100. #define PS3_AUDIO_NULL_DMA_COUNT (2)
  101. #define SND_PS3_MAX_VOL (0x0F)
  102. #define SND_PS3_MIN_VOL (0x00)
  103. #define SND_PS3_MIN_ATT SND_PS3_MIN_VOL
  104. #define SND_PS3_MAX_ATT SND_PS3_MAX_VOL
  105. #define SND_PS3_PCM_PREALLOC_SIZE \
  106. (PS3_AUDIO_DMAC_BLOCK_SIZE * PS3_AUDIO_DMAC_MAX_BLOCKS * 4)
  107. #define SND_PS3_DMA_REGION_SIZE \
  108. (SND_PS3_PCM_PREALLOC_SIZE + PAGE_SIZE)
  109. #define PS3_AUDIO_IOID (1UL)
  110. #endif /* _SND_PS3_H_ */