Javier Martin | 186b250 | 2012-07-26 05:53:35 -0300 | [diff] [blame^] | 1 | /* |
| 2 | * linux/drivers/media/video/coda/coda_regs.h |
| 3 | * |
| 4 | * Copyright (C) 2012 Vista Silicon SL |
| 5 | * Javier Martin <javier.martin@vista-silicon.com> |
| 6 | * Xavier Duret |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
| 14 | #ifndef _REGS_CODA_H_ |
| 15 | #define _REGS_CODA_H_ |
| 16 | |
| 17 | /* HW registers */ |
| 18 | #define CODA_REG_BIT_CODE_RUN 0x000 |
| 19 | #define CODA_REG_RUN_ENABLE (1 << 0) |
| 20 | #define CODA_REG_BIT_CODE_DOWN 0x004 |
| 21 | #define CODA_DOWN_ADDRESS_SET(x) (((x) & 0xffff) << 16) |
| 22 | #define CODA_DOWN_DATA_SET(x) ((x) & 0xffff) |
| 23 | #define CODA_REG_BIT_HOST_IN_REQ 0x008 |
| 24 | #define CODA_REG_BIT_INT_CLEAR 0x00c |
| 25 | #define CODA_REG_BIT_INT_CLEAR_SET 0x1 |
| 26 | #define CODA_REG_BIT_INT_STATUS 0x010 |
| 27 | #define CODA_REG_BIT_CODE_RESET 0x014 |
| 28 | #define CODA_REG_RESET_ENABLE (1 << 0) |
| 29 | #define CODA_REG_BIT_CUR_PC 0x018 |
| 30 | |
| 31 | /* Static SW registers */ |
| 32 | #define CODA_REG_BIT_CODE_BUF_ADDR 0x100 |
| 33 | #define CODA_REG_BIT_WORK_BUF_ADDR 0x104 |
| 34 | #define CODA_REG_BIT_PARA_BUF_ADDR 0x108 |
| 35 | #define CODA_REG_BIT_STREAM_CTRL 0x10c |
| 36 | #define CODA7_STREAM_BUF_PIC_RESET (1 << 4) |
| 37 | #define CODADX6_STREAM_BUF_PIC_RESET (1 << 3) |
| 38 | #define CODA7_STREAM_BUF_PIC_FLUSH (1 << 3) |
| 39 | #define CODADX6_STREAM_BUF_PIC_FLUSH (1 << 2) |
| 40 | #define CODA7_STREAM_BUF_DYNALLOC_EN (1 << 5) |
| 41 | #define CODADX6_STREAM_BUF_DYNALLOC_EN (1 << 4) |
| 42 | #define CODA_STREAM_CHKDIS_OFFSET (1 << 1) |
| 43 | #define CODA_STREAM_ENDIAN_SELECT (1 << 0) |
| 44 | #define CODA_REG_BIT_FRAME_MEM_CTRL 0x110 |
| 45 | #define CODA_IMAGE_ENDIAN_SELECT (1 << 0) |
| 46 | #define CODA_REG_BIT_RD_PTR(x) (0x120 + 8 * (x)) |
| 47 | #define CODA_REG_BIT_WR_PTR(x) (0x124 + 8 * (x)) |
| 48 | #define CODA_REG_BIT_SEARCH_RAM_BASE_ADDR 0x140 |
| 49 | #define CODA_REG_BIT_BUSY 0x160 |
| 50 | #define CODA_REG_BIT_BUSY_FLAG 1 |
| 51 | #define CODA_REG_BIT_RUN_COMMAND 0x164 |
| 52 | #define CODA_COMMAND_SEQ_INIT 1 |
| 53 | #define CODA_COMMAND_SEQ_END 2 |
| 54 | #define CODA_COMMAND_PIC_RUN 3 |
| 55 | #define CODA_COMMAND_SET_FRAME_BUF 4 |
| 56 | #define CODA_COMMAND_ENCODE_HEADER 5 |
| 57 | #define CODA_COMMAND_ENC_PARA_SET 6 |
| 58 | #define CODA_COMMAND_DEC_PARA_SET 7 |
| 59 | #define CODA_COMMAND_DEC_BUF_FLUSH 8 |
| 60 | #define CODA_COMMAND_RC_CHANGE_PARAMETER 9 |
| 61 | #define CODA_COMMAND_FIRMWARE_GET 0xf |
| 62 | #define CODA_REG_BIT_RUN_INDEX 0x168 |
| 63 | #define CODA_INDEX_SET(x) ((x) & 0x3) |
| 64 | #define CODA_REG_BIT_RUN_COD_STD 0x16c |
| 65 | #define CODADX6_MODE_DECODE_MP4 0 |
| 66 | #define CODADX6_MODE_ENCODE_MP4 1 |
| 67 | #define CODADX6_MODE_DECODE_H264 2 |
| 68 | #define CODADX6_MODE_ENCODE_H264 3 |
| 69 | #define CODA7_MODE_DECODE_H264 0 |
| 70 | #define CODA7_MODE_DECODE_VC1 1 |
| 71 | #define CODA7_MODE_DECODE_MP2 2 |
| 72 | #define CODA7_MODE_DECODE_MP4 3 |
| 73 | #define CODA7_MODE_DECODE_DV3 3 |
| 74 | #define CODA7_MODE_DECODE_RV 4 |
| 75 | #define CODA7_MODE_DECODE_MJPG 5 |
| 76 | #define CODA7_MODE_ENCODE_H264 8 |
| 77 | #define CODA7_MODE_ENCODE_MP4 11 |
| 78 | #define CODA7_MODE_ENCODE_MJPG 13 |
| 79 | #define CODA_MODE_INVALID 0xffff |
| 80 | #define CODA_REG_BIT_INT_ENABLE 0x170 |
| 81 | #define CODA_INT_INTERRUPT_ENABLE (1 << 3) |
| 82 | |
| 83 | /* |
| 84 | * Commands' mailbox: |
| 85 | * registers with offsets in the range 0x180-0x1d0 |
| 86 | * have different meaning depending on the command being |
| 87 | * issued. |
| 88 | */ |
| 89 | |
| 90 | /* Encoder Sequence Initialization */ |
| 91 | #define CODA_CMD_ENC_SEQ_BB_START 0x180 |
| 92 | #define CODA_CMD_ENC_SEQ_BB_SIZE 0x184 |
| 93 | #define CODA_CMD_ENC_SEQ_OPTION 0x188 |
| 94 | #define CODA_OPTION_GAMMA_OFFSET 7 |
| 95 | #define CODA_OPTION_GAMMA_MASK 0x01 |
| 96 | #define CODA_OPTION_LIMITQP_OFFSET 6 |
| 97 | #define CODA_OPTION_LIMITQP_MASK 0x01 |
| 98 | #define CODA_OPTION_RCINTRAQP_OFFSET 5 |
| 99 | #define CODA_OPTION_RCINTRAQP_MASK 0x01 |
| 100 | #define CODA_OPTION_FMO_OFFSET 4 |
| 101 | #define CODA_OPTION_FMO_MASK 0x01 |
| 102 | #define CODA_OPTION_SLICEREPORT_OFFSET 1 |
| 103 | #define CODA_OPTION_SLICEREPORT_MASK 0x01 |
| 104 | #define CODA_CMD_ENC_SEQ_COD_STD 0x18c |
| 105 | #define CODA_STD_MPEG4 0 |
| 106 | #define CODA_STD_H263 1 |
| 107 | #define CODA_STD_H264 2 |
| 108 | #define CODA_STD_MJPG 3 |
| 109 | #define CODA_CMD_ENC_SEQ_SRC_SIZE 0x190 |
| 110 | #define CODA7_PICWIDTH_OFFSET 16 |
| 111 | #define CODA7_PICWIDTH_MASK 0xffff |
| 112 | #define CODADX6_PICWIDTH_OFFSET 10 |
| 113 | #define CODADX6_PICWIDTH_MASK 0x3ff |
| 114 | #define CODA_PICHEIGHT_OFFSET 0 |
| 115 | #define CODA_PICHEIGHT_MASK 0x3ff |
| 116 | #define CODA_CMD_ENC_SEQ_SRC_F_RATE 0x194 |
| 117 | #define CODA_CMD_ENC_SEQ_MP4_PARA 0x198 |
| 118 | #define CODA_MP4PARAM_VERID_OFFSET 6 |
| 119 | #define CODA_MP4PARAM_VERID_MASK 0x01 |
| 120 | #define CODA_MP4PARAM_INTRADCVLCTHR_OFFSET 2 |
| 121 | #define CODA_MP4PARAM_INTRADCVLCTHR_MASK 0x07 |
| 122 | #define CODA_MP4PARAM_REVERSIBLEVLCENABLE_OFFSET 1 |
| 123 | #define CODA_MP4PARAM_REVERSIBLEVLCENABLE_MASK 0x01 |
| 124 | #define CODA_MP4PARAM_DATAPARTITIONENABLE_OFFSET 0 |
| 125 | #define CODA_MP4PARAM_DATAPARTITIONENABLE_MASK 0x01 |
| 126 | #define CODA_CMD_ENC_SEQ_263_PARA 0x19c |
| 127 | #define CODA_263PARAM_ANNEXJENABLE_OFFSET 2 |
| 128 | #define CODA_263PARAM_ANNEXJENABLE_MASK 0x01 |
| 129 | #define CODA_263PARAM_ANNEXKENABLE_OFFSET 1 |
| 130 | #define CODA_263PARAM_ANNEXKENABLE_MASK 0x01 |
| 131 | #define CODA_263PARAM_ANNEXTENABLE_OFFSET 0 |
| 132 | #define CODA_263PARAM_ANNEXTENABLE_MASK 0x01 |
| 133 | #define CODA_CMD_ENC_SEQ_264_PARA 0x1a0 |
| 134 | #define CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET 12 |
| 135 | #define CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK 0x0f |
| 136 | #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET 8 |
| 137 | #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK 0x0f |
| 138 | #define CODA_264PARAM_DISABLEDEBLK_OFFSET 6 |
| 139 | #define CODA_264PARAM_DISABLEDEBLK_MASK 0x01 |
| 140 | #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET 5 |
| 141 | #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK 0x01 |
| 142 | #define CODA_264PARAM_CHROMAQPOFFSET_OFFSET 0 |
| 143 | #define CODA_264PARAM_CHROMAQPOFFSET_MASK 0x1f |
| 144 | #define CODA_CMD_ENC_SEQ_SLICE_MODE 0x1a4 |
| 145 | #define CODA_SLICING_SIZE_OFFSET 2 |
| 146 | #define CODA_SLICING_SIZE_MASK 0x3fffffff |
| 147 | #define CODA_SLICING_UNIT_OFFSET 1 |
| 148 | #define CODA_SLICING_UNIT_MASK 0x01 |
| 149 | #define CODA_SLICING_MODE_OFFSET 0 |
| 150 | #define CODA_SLICING_MODE_MASK 0x01 |
| 151 | #define CODA_CMD_ENC_SEQ_GOP_SIZE 0x1a8 |
| 152 | #define CODA_GOP_SIZE_OFFSET 0 |
| 153 | #define CODA_GOP_SIZE_MASK 0x3f |
| 154 | #define CODA_CMD_ENC_SEQ_RC_PARA 0x1ac |
| 155 | #define CODA_RATECONTROL_AUTOSKIP_OFFSET 31 |
| 156 | #define CODA_RATECONTROL_AUTOSKIP_MASK 0x01 |
| 157 | #define CODA_RATECONTROL_INITIALDELAY_OFFSET 16 |
| 158 | #define CODA_RATECONTROL_INITIALDELAY_MASK 0x7f |
| 159 | #define CODA_RATECONTROL_BITRATE_OFFSET 1 |
| 160 | #define CODA_RATECONTROL_BITRATE_MASK 0x7f |
| 161 | #define CODA_RATECONTROL_ENABLE_OFFSET 0 |
| 162 | #define CODA_RATECONTROL_ENABLE_MASK 0x01 |
| 163 | #define CODA_CMD_ENC_SEQ_RC_BUF_SIZE 0x1b0 |
| 164 | #define CODA_CMD_ENC_SEQ_INTRA_REFRESH 0x1b4 |
| 165 | #define CODA_CMD_ENC_SEQ_FMO 0x1b8 |
| 166 | #define CODA_FMOPARAM_TYPE_OFFSET 4 |
| 167 | #define CODA_FMOPARAM_TYPE_MASK 1 |
| 168 | #define CODA_FMOPARAM_SLICENUM_OFFSET 0 |
| 169 | #define CODA_FMOPARAM_SLICENUM_MASK 0x0f |
| 170 | #define CODA_CMD_ENC_SEQ_RC_QP_MAX 0x1c8 |
| 171 | #define CODA_QPMAX_OFFSET 0 |
| 172 | #define CODA_QPMAX_MASK 0x3f |
| 173 | #define CODA_CMD_ENC_SEQ_RC_GAMMA 0x1cc |
| 174 | #define CODA_GAMMA_OFFSET 0 |
| 175 | #define CODA_GAMMA_MASK 0xffff |
| 176 | #define CODA_RET_ENC_SEQ_SUCCESS 0x1c0 |
| 177 | |
| 178 | /* Encoder Picture Run */ |
| 179 | #define CODA_CMD_ENC_PIC_SRC_ADDR_Y 0x180 |
| 180 | #define CODA_CMD_ENC_PIC_SRC_ADDR_CB 0x184 |
| 181 | #define CODA_CMD_ENC_PIC_SRC_ADDR_CR 0x188 |
| 182 | #define CODA_CMD_ENC_PIC_QS 0x18c |
| 183 | #define CODA_CMD_ENC_PIC_ROT_MODE 0x190 |
| 184 | #define CODA_CMD_ENC_PIC_OPTION 0x194 |
| 185 | #define CODA_CMD_ENC_PIC_BB_START 0x198 |
| 186 | #define CODA_CMD_ENC_PIC_BB_SIZE 0x19c |
| 187 | #define CODA_RET_ENC_PIC_TYPE 0x1c4 |
| 188 | #define CODA_RET_ENC_PIC_SLICE_NUM 0x1cc |
| 189 | #define CODA_RET_ENC_PIC_FLAG 0x1d0 |
| 190 | |
| 191 | /* Set Frame Buffer */ |
| 192 | #define CODA_CMD_SET_FRAME_BUF_NUM 0x180 |
| 193 | #define CODA_CMD_SET_FRAME_BUF_STRIDE 0x184 |
| 194 | |
| 195 | /* Encoder Header */ |
| 196 | #define CODA_CMD_ENC_HEADER_CODE 0x180 |
| 197 | #define CODA_GAMMA_OFFSET 0 |
| 198 | #define CODA_HEADER_H264_SPS 0 |
| 199 | #define CODA_HEADER_H264_PPS 1 |
| 200 | #define CODA_HEADER_MP4V_VOL 0 |
| 201 | #define CODA_HEADER_MP4V_VOS 1 |
| 202 | #define CODA_HEADER_MP4V_VIS 2 |
| 203 | #define CODA_CMD_ENC_HEADER_BB_START 0x184 |
| 204 | #define CODA_CMD_ENC_HEADER_BB_SIZE 0x188 |
| 205 | |
| 206 | /* Get Version */ |
| 207 | #define CODA_CMD_FIRMWARE_VERNUM 0x1c0 |
| 208 | #define CODA_FIRMWARE_PRODUCT(x) (((x) >> 16) & 0xffff) |
| 209 | #define CODA_FIRMWARE_MAJOR(x) (((x) >> 12) & 0x0f) |
| 210 | #define CODA_FIRMWARE_MINOR(x) (((x) >> 8) & 0x0f) |
| 211 | #define CODA_FIRMWARE_RELEASE(x) ((x) & 0xff) |
| 212 | #define CODA_FIRMWARE_VERNUM(product, major, minor, release) \ |
| 213 | ((product) << 16 | ((major) << 12) | \ |
| 214 | ((minor) << 8) | (release)) |
| 215 | |
| 216 | #endif |