saa7164-reg.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * Driver for the NXP SAA7164 PCIe bridge
  3. *
  4. * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  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. *
  15. * GNU General Public License for more details.
  16. */
  17. /* TODO: Retest the driver with errors expressed as negatives */
  18. /* Result codes */
  19. #define SAA_OK 0
  20. #define SAA_ERR_BAD_PARAMETER 0x09
  21. #define SAA_ERR_NO_RESOURCES 0x0c
  22. #define SAA_ERR_NOT_SUPPORTED 0x13
  23. #define SAA_ERR_BUSY 0x15
  24. #define SAA_ERR_READ 0x17
  25. #define SAA_ERR_TIMEOUT 0x1f
  26. #define SAA_ERR_OVERFLOW 0x20
  27. #define SAA_ERR_EMPTY 0x22
  28. #define SAA_ERR_NOT_STARTED 0x23
  29. #define SAA_ERR_ALREADY_STARTED 0x24
  30. #define SAA_ERR_NOT_STOPPED 0x25
  31. #define SAA_ERR_ALREADY_STOPPED 0x26
  32. #define SAA_ERR_INVALID_COMMAND 0x3e
  33. #define SAA_ERR_NULL_PACKET 0x59
  34. /* Errors and flags from the silicon */
  35. #define PVC_ERRORCODE_UNKNOWN 0x00
  36. #define PVC_ERRORCODE_INVALID_COMMAND 0x01
  37. #define PVC_ERRORCODE_INVALID_CONTROL 0x02
  38. #define PVC_ERRORCODE_INVALID_DATA 0x03
  39. #define PVC_ERRORCODE_TIMEOUT 0x04
  40. #define PVC_ERRORCODE_NAK 0x05
  41. #define PVC_RESPONSEFLAG_ERROR 0x01
  42. #define PVC_RESPONSEFLAG_OVERFLOW 0x02
  43. #define PVC_RESPONSEFLAG_RESET 0x04
  44. #define PVC_RESPONSEFLAG_INTERFACE 0x08
  45. #define PVC_RESPONSEFLAG_CONTINUED 0x10
  46. #define PVC_CMDFLAG_INTERRUPT 0x02
  47. #define PVC_CMDFLAG_INTERFACE 0x04
  48. #define PVC_CMDFLAG_SERIALIZE 0x08
  49. #define PVC_CMDFLAG_CONTINUE 0x10
  50. /* Silicon Commands */
  51. #define GET_DESCRIPTORS_CONTROL 0x01
  52. #define GET_STRING_CONTROL 0x03
  53. #define GET_LANGUAGE_CONTROL 0x05
  54. #define SET_POWER_CONTROL 0x07
  55. #define GET_FW_STATUS_CONTROL 0x08
  56. #define GET_FW_VERSION_CONTROL 0x09
  57. #define SET_DEBUG_LEVEL_CONTROL 0x0B
  58. #define GET_DEBUG_DATA_CONTROL 0x0C
  59. #define GET_PRODUCTION_INFO_CONTROL 0x0D
  60. /* cmd defines */
  61. #define SAA_CMDFLAG_CONTINUE 0x10
  62. #define SAA_CMD_MAX_MSG_UNITS 256
  63. /* Some defines */
  64. #define SAA_BUS_TIMEOUT 50
  65. #define SAA_DEVICE_TIMEOUT 5000
  66. #define SAA_DEVICE_MAXREQUESTSIZE 256
  67. /* Register addresses */
  68. #define SAA_DEVICE_VERSION 0x30
  69. #define SAA_DOWNLOAD_FLAGS 0x34
  70. #define SAA_DOWNLOAD_FLAG 0x34
  71. #define SAA_DOWNLOAD_FLAG_ACK 0x38
  72. #define SAA_DATAREADY_FLAG 0x3C
  73. #define SAA_DATAREADY_FLAG_ACK 0x40
  74. /* Boot loader register and bit definitions */
  75. #define SAA_BOOTLOADERERROR_FLAGS 0x44
  76. #define SAA_DEVICE_IMAGE_SEARCHING 0x01
  77. #define SAA_DEVICE_IMAGE_LOADING 0x02
  78. #define SAA_DEVICE_IMAGE_BOOTING 0x03
  79. #define SAA_DEVICE_IMAGE_CORRUPT 0x04
  80. #define SAA_DEVICE_MEMORY_CORRUPT 0x08
  81. #define SAA_DEVICE_NO_IMAGE 0x10
  82. /* Register addresses */
  83. #define SAA_DEVICE_2ND_VERSION 0x50
  84. #define SAA_DEVICE_2ND_DOWNLOADFLAG_OFFSET 0x54
  85. /* Register addresses */
  86. #define SAA_SECONDSTAGEERROR_FLAGS 0x64
  87. /* Bootloader regs and flags */
  88. #define SAA_DEVICE_DEADLOCK_DETECTED_OFFSET 0x6C
  89. #define SAA_DEVICE_DEADLOCK_DETECTED 0xDEADDEAD
  90. /* Basic firmware status registers */
  91. #define SAA_DEVICE_SYSINIT_STATUS_OFFSET 0x70
  92. #define SAA_DEVICE_SYSINIT_STATUS 0x70
  93. #define SAA_DEVICE_SYSINIT_MODE 0x74
  94. #define SAA_DEVICE_SYSINIT_SPEC 0x78
  95. #define SAA_DEVICE_SYSINIT_INST 0x7C
  96. #define SAA_DEVICE_SYSINIT_CPULOAD 0x80
  97. #define SAA_DEVICE_SYSINIT_REMAINHEAP 0x84
  98. #define SAA_DEVICE_DOWNLOAD_OFFSET 0x1000
  99. #define SAA_DEVICE_BUFFERBLOCKSIZE 0x1000
  100. #define SAA_DEVICE_2ND_BUFFERBLOCKSIZE 0x100000
  101. #define SAA_DEVICE_2ND_DOWNLOAD_OFFSET 0x200000
  102. /* Descriptors */
  103. #define CS_INTERFACE 0x24
  104. /* Descriptor subtypes */
  105. #define VC_INPUT_TERMINAL 0x02
  106. #define VC_OUTPUT_TERMINAL 0x03
  107. #define VC_SELECTOR_UNIT 0x04
  108. #define VC_PROCESSING_UNIT 0x05
  109. #define FEATURE_UNIT 0x06
  110. #define TUNER_UNIT 0x09
  111. #define ENCODER_UNIT 0x0A
  112. #define EXTENSION_UNIT 0x0B
  113. #define VC_TUNER_PATH 0xF0
  114. #define PVC_HARDWARE_DESCRIPTOR 0xF1
  115. #define PVC_INTERFACE_DESCRIPTOR 0xF2
  116. #define PVC_INFRARED_UNIT 0xF3
  117. #define DRM_UNIT 0xF4
  118. #define GENERAL_REQUEST 0xF5
  119. /* Format Types */
  120. #define VS_FORMAT_TYPE 0x02
  121. #define VS_FORMAT_TYPE_I 0x01
  122. #define VS_FORMAT_UNCOMPRESSED 0x04
  123. #define VS_FRAME_UNCOMPRESSED 0x05
  124. #define VS_FORMAT_MPEG2PS 0x09
  125. #define VS_FORMAT_MPEG2TS 0x0A
  126. #define VS_FORMAT_MPEG4SL 0x0B
  127. #define VS_FORMAT_WM9 0x0C
  128. #define VS_FORMAT_DIVX 0x0D
  129. #define VS_FORMAT_VBI 0x0E
  130. #define VS_FORMAT_RDS 0x0F
  131. /* Device extension commands */
  132. #define EXU_REGISTER_ACCESS_CONTROL 0x00
  133. #define EXU_GPIO_CONTROL 0x01
  134. #define EXU_GPIO_GROUP_CONTROL 0x02
  135. #define EXU_INTERRUPT_CONTROL 0x03
  136. /* State Transition and args */
  137. #define SAA_PROBE_CONTROL 0x01
  138. #define SAA_COMMIT_CONTROL 0x02
  139. #define SAA_STATE_CONTROL 0x03
  140. #define SAA_DMASTATE_STOP 0x00
  141. #define SAA_DMASTATE_ACQUIRE 0x01
  142. #define SAA_DMASTATE_PAUSE 0x02
  143. #define SAA_DMASTATE_RUN 0x03
  144. /* A/V Mux Input Selector */
  145. #define SU_INPUT_SELECT_CONTROL 0x01
  146. /* Encoder Profiles */
  147. #define EU_PROFILE_PS_DVD 0x06
  148. #define EU_PROFILE_TS_HQ 0x09
  149. #define EU_VIDEO_FORMAT_MPEG_2 0x02
  150. /* Tuner */
  151. #define TU_AUDIO_MODE_CONTROL 0x17
  152. /* Video Formats */
  153. #define TU_STANDARD_CONTROL 0x00
  154. #define TU_STANDARD_AUTO_CONTROL 0x01
  155. #define TU_STANDARD_NONE 0x00
  156. #define TU_STANDARD_NTSC_M 0x01
  157. #define TU_STANDARD_PAL_I 0x08
  158. #define TU_STANDARD_MANUAL 0x00
  159. #define TU_STANDARD_AUTO 0x01
  160. /* Video Controls */
  161. #define PU_BRIGHTNESS_CONTROL 0x02
  162. #define PU_CONTRAST_CONTROL 0x03
  163. #define PU_HUE_CONTROL 0x06
  164. #define PU_SATURATION_CONTROL 0x07
  165. #define PU_SHARPNESS_CONTROL 0x08
  166. /* Audio Controls */
  167. #define MUTE_CONTROL 0x01
  168. #define VOLUME_CONTROL 0x02
  169. #define AUDIO_DEFAULT_CONTROL 0x0D
  170. /* Default Volume Levels */
  171. #define TMHW_LEV_ADJ_DECLEV_DEFAULT 0x00
  172. #define TMHW_LEV_ADJ_MONOLEV_DEFAULT 0x00
  173. #define TMHW_LEV_ADJ_NICLEV_DEFAULT 0x00
  174. #define TMHW_LEV_ADJ_SAPLEV_DEFAULT 0x00
  175. #define TMHW_LEV_ADJ_ADCLEV_DEFAULT 0x00
  176. /* Encoder Related Commands */
  177. #define EU_PROFILE_CONTROL 0x00
  178. #define EU_VIDEO_FORMAT_CONTROL 0x01
  179. #define EU_VIDEO_BIT_RATE_CONTROL 0x02
  180. #define EU_VIDEO_RESOLUTION_CONTROL 0x03
  181. #define EU_VIDEO_GOP_STRUCTURE_CONTROL 0x04
  182. #define EU_VIDEO_INPUT_ASPECT_CONTROL 0x0A
  183. #define EU_AUDIO_FORMAT_CONTROL 0x0C
  184. #define EU_AUDIO_BIT_RATE_CONTROL 0x0D
  185. /* Firmware Debugging */
  186. #define SET_DEBUG_LEVEL_CONTROL 0x0B
  187. #define GET_DEBUG_DATA_CONTROL 0x0C