1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2013 Advanced Micro Devices, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#ifndef RADEON_VCE_H 29bf215546Sopenharmony_ci#define RADEON_VCE_H 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "radeon_video.h" 32bf215546Sopenharmony_ci#include "util/list.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#define RVCE_CS(value) (enc->cs.current.buf[enc->cs.current.cdw++] = (value)) 35bf215546Sopenharmony_ci#define RVCE_BEGIN(cmd) \ 36bf215546Sopenharmony_ci { \ 37bf215546Sopenharmony_ci uint32_t *begin = &enc->cs.current.buf[enc->cs.current.cdw++]; \ 38bf215546Sopenharmony_ci RVCE_CS(cmd) 39bf215546Sopenharmony_ci#define RVCE_READ(buf, domain, off) \ 40bf215546Sopenharmony_ci si_vce_add_buffer(enc, (buf), RADEON_USAGE_READ, (domain), (off)) 41bf215546Sopenharmony_ci#define RVCE_WRITE(buf, domain, off) \ 42bf215546Sopenharmony_ci si_vce_add_buffer(enc, (buf), RADEON_USAGE_WRITE, (domain), (off)) 43bf215546Sopenharmony_ci#define RVCE_READWRITE(buf, domain, off) \ 44bf215546Sopenharmony_ci si_vce_add_buffer(enc, (buf), RADEON_USAGE_READWRITE, (domain), (off)) 45bf215546Sopenharmony_ci#define RVCE_END() \ 46bf215546Sopenharmony_ci *begin = (&enc->cs.current.buf[enc->cs.current.cdw] - begin) * 4; \ 47bf215546Sopenharmony_ci } 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE (4096 * 16 * 2.5) 50bf215546Sopenharmony_ci#define RVCE_MAX_AUX_BUFFER_NUM 4 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_cistruct si_screen; 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci/* driver dependent callback */ 55bf215546Sopenharmony_citypedef void (*rvce_get_buffer)(struct pipe_resource *resource, struct pb_buffer **handle, 56bf215546Sopenharmony_ci struct radeon_surf **surface); 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci/* Coded picture buffer slot */ 59bf215546Sopenharmony_cistruct rvce_cpb_slot { 60bf215546Sopenharmony_ci struct list_head list; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci unsigned index; 63bf215546Sopenharmony_ci enum pipe_h2645_enc_picture_type picture_type; 64bf215546Sopenharmony_ci unsigned frame_num; 65bf215546Sopenharmony_ci unsigned pic_order_cnt; 66bf215546Sopenharmony_ci}; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_cistruct rvce_rate_control { 69bf215546Sopenharmony_ci uint32_t rc_method; 70bf215546Sopenharmony_ci uint32_t target_bitrate; 71bf215546Sopenharmony_ci uint32_t peak_bitrate; 72bf215546Sopenharmony_ci uint32_t frame_rate_num; 73bf215546Sopenharmony_ci uint32_t gop_size; 74bf215546Sopenharmony_ci uint32_t quant_i_frames; 75bf215546Sopenharmony_ci uint32_t quant_p_frames; 76bf215546Sopenharmony_ci uint32_t quant_b_frames; 77bf215546Sopenharmony_ci uint32_t vbv_buffer_size; 78bf215546Sopenharmony_ci uint32_t frame_rate_den; 79bf215546Sopenharmony_ci uint32_t vbv_buf_lv; 80bf215546Sopenharmony_ci uint32_t max_au_size; 81bf215546Sopenharmony_ci uint32_t qp_initial_mode; 82bf215546Sopenharmony_ci uint32_t target_bits_picture; 83bf215546Sopenharmony_ci uint32_t peak_bits_picture_integer; 84bf215546Sopenharmony_ci uint32_t peak_bits_picture_fraction; 85bf215546Sopenharmony_ci uint32_t min_qp; 86bf215546Sopenharmony_ci uint32_t max_qp; 87bf215546Sopenharmony_ci uint32_t skip_frame_enable; 88bf215546Sopenharmony_ci uint32_t fill_data_enable; 89bf215546Sopenharmony_ci uint32_t enforce_hrd; 90bf215546Sopenharmony_ci uint32_t b_pics_delta_qp; 91bf215546Sopenharmony_ci uint32_t ref_b_pics_delta_qp; 92bf215546Sopenharmony_ci uint32_t rc_reinit_disable; 93bf215546Sopenharmony_ci uint32_t enc_lcvbr_init_qp_flag; 94bf215546Sopenharmony_ci uint32_t lcvbrsatd_based_nonlinear_bit_budget_flag; 95bf215546Sopenharmony_ci}; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_cistruct rvce_motion_estimation { 98bf215546Sopenharmony_ci uint32_t enc_ime_decimation_search; 99bf215546Sopenharmony_ci uint32_t motion_est_half_pixel; 100bf215546Sopenharmony_ci uint32_t motion_est_quarter_pixel; 101bf215546Sopenharmony_ci uint32_t disable_favor_pmv_point; 102bf215546Sopenharmony_ci uint32_t force_zero_point_center; 103bf215546Sopenharmony_ci uint32_t lsmvert; 104bf215546Sopenharmony_ci uint32_t enc_search_range_x; 105bf215546Sopenharmony_ci uint32_t enc_search_range_y; 106bf215546Sopenharmony_ci uint32_t enc_search1_range_x; 107bf215546Sopenharmony_ci uint32_t enc_search1_range_y; 108bf215546Sopenharmony_ci uint32_t disable_16x16_frame1; 109bf215546Sopenharmony_ci uint32_t disable_satd; 110bf215546Sopenharmony_ci uint32_t enable_amd; 111bf215546Sopenharmony_ci uint32_t enc_disable_sub_mode; 112bf215546Sopenharmony_ci uint32_t enc_ime_skip_x; 113bf215546Sopenharmony_ci uint32_t enc_ime_skip_y; 114bf215546Sopenharmony_ci uint32_t enc_en_ime_overw_dis_subm; 115bf215546Sopenharmony_ci uint32_t enc_ime_overw_dis_subm_no; 116bf215546Sopenharmony_ci uint32_t enc_ime2_search_range_x; 117bf215546Sopenharmony_ci uint32_t enc_ime2_search_range_y; 118bf215546Sopenharmony_ci uint32_t parallel_mode_speedup_enable; 119bf215546Sopenharmony_ci uint32_t fme0_enc_disable_sub_mode; 120bf215546Sopenharmony_ci uint32_t fme1_enc_disable_sub_mode; 121bf215546Sopenharmony_ci uint32_t ime_sw_speedup_enable; 122bf215546Sopenharmony_ci}; 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_cistruct rvce_pic_control { 125bf215546Sopenharmony_ci uint32_t enc_use_constrained_intra_pred; 126bf215546Sopenharmony_ci uint32_t enc_cabac_enable; 127bf215546Sopenharmony_ci uint32_t enc_cabac_idc; 128bf215546Sopenharmony_ci uint32_t enc_loop_filter_disable; 129bf215546Sopenharmony_ci int32_t enc_lf_beta_offset; 130bf215546Sopenharmony_ci int32_t enc_lf_alpha_c0_offset; 131bf215546Sopenharmony_ci uint32_t enc_crop_left_offset; 132bf215546Sopenharmony_ci uint32_t enc_crop_right_offset; 133bf215546Sopenharmony_ci uint32_t enc_crop_top_offset; 134bf215546Sopenharmony_ci uint32_t enc_crop_bottom_offset; 135bf215546Sopenharmony_ci uint32_t enc_num_mbs_per_slice; 136bf215546Sopenharmony_ci uint32_t enc_intra_refresh_num_mbs_per_slot; 137bf215546Sopenharmony_ci uint32_t enc_force_intra_refresh; 138bf215546Sopenharmony_ci uint32_t enc_force_imb_period; 139bf215546Sopenharmony_ci uint32_t enc_pic_order_cnt_type; 140bf215546Sopenharmony_ci uint32_t log2_max_pic_order_cnt_lsb_minus4; 141bf215546Sopenharmony_ci uint32_t enc_sps_id; 142bf215546Sopenharmony_ci uint32_t enc_pps_id; 143bf215546Sopenharmony_ci uint32_t enc_constraint_set_flags; 144bf215546Sopenharmony_ci uint32_t enc_b_pic_pattern; 145bf215546Sopenharmony_ci uint32_t weight_pred_mode_b_picture; 146bf215546Sopenharmony_ci uint32_t enc_number_of_reference_frames; 147bf215546Sopenharmony_ci uint32_t enc_max_num_ref_frames; 148bf215546Sopenharmony_ci uint32_t enc_num_default_active_ref_l0; 149bf215546Sopenharmony_ci uint32_t enc_num_default_active_ref_l1; 150bf215546Sopenharmony_ci uint32_t enc_slice_mode; 151bf215546Sopenharmony_ci uint32_t enc_max_slice_size; 152bf215546Sopenharmony_ci}; 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_cistruct rvce_task_info { 155bf215546Sopenharmony_ci uint32_t offset_of_next_task_info; 156bf215546Sopenharmony_ci uint32_t task_operation; 157bf215546Sopenharmony_ci uint32_t reference_picture_dependency; 158bf215546Sopenharmony_ci uint32_t collocate_flag_dependency; 159bf215546Sopenharmony_ci uint32_t feedback_index; 160bf215546Sopenharmony_ci uint32_t video_bitstream_ring_index; 161bf215546Sopenharmony_ci}; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_cistruct rvce_feedback_buf_pkg { 164bf215546Sopenharmony_ci uint32_t feedback_ring_address_hi; 165bf215546Sopenharmony_ci uint32_t feedback_ring_address_lo; 166bf215546Sopenharmony_ci uint32_t feedback_ring_size; 167bf215546Sopenharmony_ci}; 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_cistruct rvce_rdo { 170bf215546Sopenharmony_ci uint32_t enc_disable_tbe_pred_i_frame; 171bf215546Sopenharmony_ci uint32_t enc_disable_tbe_pred_p_frame; 172bf215546Sopenharmony_ci uint32_t use_fme_interpol_y; 173bf215546Sopenharmony_ci uint32_t use_fme_interpol_uv; 174bf215546Sopenharmony_ci uint32_t use_fme_intrapol_y; 175bf215546Sopenharmony_ci uint32_t use_fme_intrapol_uv; 176bf215546Sopenharmony_ci uint32_t use_fme_interpol_y_1; 177bf215546Sopenharmony_ci uint32_t use_fme_interpol_uv_1; 178bf215546Sopenharmony_ci uint32_t use_fme_intrapol_y_1; 179bf215546Sopenharmony_ci uint32_t use_fme_intrapol_uv_1; 180bf215546Sopenharmony_ci uint32_t enc_16x16_cost_adj; 181bf215546Sopenharmony_ci uint32_t enc_skip_cost_adj; 182bf215546Sopenharmony_ci uint32_t enc_force_16x16_skip; 183bf215546Sopenharmony_ci uint32_t enc_disable_threshold_calc_a; 184bf215546Sopenharmony_ci uint32_t enc_luma_coeff_cost; 185bf215546Sopenharmony_ci uint32_t enc_luma_mb_coeff_cost; 186bf215546Sopenharmony_ci uint32_t enc_chroma_coeff_cost; 187bf215546Sopenharmony_ci}; 188bf215546Sopenharmony_ci 189bf215546Sopenharmony_cistruct rvce_vui { 190bf215546Sopenharmony_ci uint32_t aspect_ratio_info_present_flag; 191bf215546Sopenharmony_ci uint32_t aspect_ratio_idc; 192bf215546Sopenharmony_ci uint32_t sar_width; 193bf215546Sopenharmony_ci uint32_t sar_height; 194bf215546Sopenharmony_ci uint32_t overscan_info_present_flag; 195bf215546Sopenharmony_ci uint32_t overscan_Approp_flag; 196bf215546Sopenharmony_ci uint32_t video_signal_type_present_flag; 197bf215546Sopenharmony_ci uint32_t video_format; 198bf215546Sopenharmony_ci uint32_t video_full_range_flag; 199bf215546Sopenharmony_ci uint32_t color_description_present_flag; 200bf215546Sopenharmony_ci uint32_t color_prim; 201bf215546Sopenharmony_ci uint32_t transfer_char; 202bf215546Sopenharmony_ci uint32_t matrix_coef; 203bf215546Sopenharmony_ci uint32_t chroma_loc_info_present_flag; 204bf215546Sopenharmony_ci uint32_t chroma_loc_top; 205bf215546Sopenharmony_ci uint32_t chroma_loc_bottom; 206bf215546Sopenharmony_ci uint32_t timing_info_present_flag; 207bf215546Sopenharmony_ci uint32_t num_units_in_tick; 208bf215546Sopenharmony_ci uint32_t time_scale; 209bf215546Sopenharmony_ci uint32_t fixed_frame_rate_flag; 210bf215546Sopenharmony_ci uint32_t nal_hrd_parameters_present_flag; 211bf215546Sopenharmony_ci uint32_t cpb_cnt_minus1; 212bf215546Sopenharmony_ci uint32_t bit_rate_scale; 213bf215546Sopenharmony_ci uint32_t cpb_size_scale; 214bf215546Sopenharmony_ci uint32_t bit_rate_value_minus; 215bf215546Sopenharmony_ci uint32_t cpb_size_value_minus; 216bf215546Sopenharmony_ci uint32_t cbr_flag; 217bf215546Sopenharmony_ci uint32_t initial_cpb_removal_delay_length_minus1; 218bf215546Sopenharmony_ci uint32_t cpb_removal_delay_length_minus1; 219bf215546Sopenharmony_ci uint32_t dpb_output_delay_length_minus1; 220bf215546Sopenharmony_ci uint32_t time_offset_length; 221bf215546Sopenharmony_ci uint32_t low_delay_hrd_flag; 222bf215546Sopenharmony_ci uint32_t pic_struct_present_flag; 223bf215546Sopenharmony_ci uint32_t bitstream_restriction_present_flag; 224bf215546Sopenharmony_ci uint32_t motion_vectors_over_pic_boundaries_flag; 225bf215546Sopenharmony_ci uint32_t max_bytes_per_pic_denom; 226bf215546Sopenharmony_ci uint32_t max_bits_per_mb_denom; 227bf215546Sopenharmony_ci uint32_t log2_max_mv_length_hori; 228bf215546Sopenharmony_ci uint32_t log2_max_mv_length_vert; 229bf215546Sopenharmony_ci uint32_t num_reorder_frames; 230bf215546Sopenharmony_ci uint32_t max_dec_frame_buffering; 231bf215546Sopenharmony_ci}; 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_cistruct rvce_enc_operation { 234bf215546Sopenharmony_ci uint32_t insert_headers; 235bf215546Sopenharmony_ci uint32_t picture_structure; 236bf215546Sopenharmony_ci uint32_t allowed_max_bitstream_size; 237bf215546Sopenharmony_ci uint32_t force_refresh_map; 238bf215546Sopenharmony_ci uint32_t insert_aud; 239bf215546Sopenharmony_ci uint32_t end_of_sequence; 240bf215546Sopenharmony_ci uint32_t end_of_stream; 241bf215546Sopenharmony_ci uint32_t input_picture_luma_address_hi; 242bf215546Sopenharmony_ci uint32_t input_picture_luma_address_lo; 243bf215546Sopenharmony_ci uint32_t input_picture_chroma_address_hi; 244bf215546Sopenharmony_ci uint32_t input_picture_chroma_address_lo; 245bf215546Sopenharmony_ci uint32_t enc_input_frame_y_pitch; 246bf215546Sopenharmony_ci uint32_t enc_input_pic_luma_pitch; 247bf215546Sopenharmony_ci uint32_t enc_input_pic_chroma_pitch; 248bf215546Sopenharmony_ci ; 249bf215546Sopenharmony_ci uint32_t enc_input_pic_addr_array; 250bf215546Sopenharmony_ci uint32_t enc_input_pic_addr_array_disable2pipe_disablemboffload; 251bf215546Sopenharmony_ci uint32_t enc_input_pic_tile_config; 252bf215546Sopenharmony_ci uint32_t enc_pic_type; 253bf215546Sopenharmony_ci uint32_t enc_idr_flag; 254bf215546Sopenharmony_ci uint32_t enc_idr_pic_id; 255bf215546Sopenharmony_ci uint32_t enc_mgs_key_pic; 256bf215546Sopenharmony_ci uint32_t enc_reference_flag; 257bf215546Sopenharmony_ci uint32_t enc_temporal_layer_index; 258bf215546Sopenharmony_ci uint32_t num_ref_idx_active_override_flag; 259bf215546Sopenharmony_ci uint32_t num_ref_idx_l0_active_minus1; 260bf215546Sopenharmony_ci uint32_t num_ref_idx_l1_active_minus1; 261bf215546Sopenharmony_ci uint32_t enc_ref_list_modification_op; 262bf215546Sopenharmony_ci uint32_t enc_ref_list_modification_num; 263bf215546Sopenharmony_ci uint32_t enc_decoded_picture_marking_op; 264bf215546Sopenharmony_ci uint32_t enc_decoded_picture_marking_num; 265bf215546Sopenharmony_ci uint32_t enc_decoded_picture_marking_idx; 266bf215546Sopenharmony_ci uint32_t enc_decoded_ref_base_picture_marking_op; 267bf215546Sopenharmony_ci uint32_t enc_decoded_ref_base_picture_marking_num; 268bf215546Sopenharmony_ci uint32_t l0_picture_structure; 269bf215546Sopenharmony_ci uint32_t l0_enc_pic_type; 270bf215546Sopenharmony_ci uint32_t l0_frame_number; 271bf215546Sopenharmony_ci uint32_t l0_picture_order_count; 272bf215546Sopenharmony_ci uint32_t l0_luma_offset; 273bf215546Sopenharmony_ci uint32_t l0_chroma_offset; 274bf215546Sopenharmony_ci uint32_t l1_picture_structure; 275bf215546Sopenharmony_ci uint32_t l1_enc_pic_type; 276bf215546Sopenharmony_ci uint32_t l1_frame_number; 277bf215546Sopenharmony_ci uint32_t l1_picture_order_count; 278bf215546Sopenharmony_ci uint32_t l1_luma_offset; 279bf215546Sopenharmony_ci uint32_t l1_chroma_offset; 280bf215546Sopenharmony_ci uint32_t enc_reconstructed_luma_offset; 281bf215546Sopenharmony_ci uint32_t enc_reconstructed_chroma_offset; 282bf215546Sopenharmony_ci ; 283bf215546Sopenharmony_ci uint32_t enc_coloc_buffer_offset; 284bf215546Sopenharmony_ci uint32_t enc_reconstructed_ref_base_picture_luma_offset; 285bf215546Sopenharmony_ci uint32_t enc_reconstructed_ref_base_picture_chroma_offset; 286bf215546Sopenharmony_ci uint32_t enc_reference_ref_base_picture_luma_offset; 287bf215546Sopenharmony_ci uint32_t enc_reference_ref_base_picture_chroma_offset; 288bf215546Sopenharmony_ci uint32_t picture_count; 289bf215546Sopenharmony_ci uint32_t frame_number; 290bf215546Sopenharmony_ci uint32_t picture_order_count; 291bf215546Sopenharmony_ci uint32_t num_i_pic_remain_in_rcgop; 292bf215546Sopenharmony_ci uint32_t num_p_pic_remain_in_rcgop; 293bf215546Sopenharmony_ci uint32_t num_b_pic_remain_in_rcgop; 294bf215546Sopenharmony_ci uint32_t num_ir_pic_remain_in_rcgop; 295bf215546Sopenharmony_ci uint32_t enable_intra_refresh; 296bf215546Sopenharmony_ci uint32_t aq_variance_en; 297bf215546Sopenharmony_ci uint32_t aq_block_size; 298bf215546Sopenharmony_ci uint32_t aq_mb_variance_sel; 299bf215546Sopenharmony_ci uint32_t aq_frame_variance_sel; 300bf215546Sopenharmony_ci uint32_t aq_param_a; 301bf215546Sopenharmony_ci uint32_t aq_param_b; 302bf215546Sopenharmony_ci uint32_t aq_param_c; 303bf215546Sopenharmony_ci uint32_t aq_param_d; 304bf215546Sopenharmony_ci uint32_t aq_param_e; 305bf215546Sopenharmony_ci uint32_t context_in_sfb; 306bf215546Sopenharmony_ci}; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_cistruct rvce_enc_create { 309bf215546Sopenharmony_ci uint32_t enc_use_circular_buffer; 310bf215546Sopenharmony_ci uint32_t enc_profile; 311bf215546Sopenharmony_ci uint32_t enc_level; 312bf215546Sopenharmony_ci uint32_t enc_pic_struct_restriction; 313bf215546Sopenharmony_ci uint32_t enc_image_width; 314bf215546Sopenharmony_ci uint32_t enc_image_height; 315bf215546Sopenharmony_ci uint32_t enc_ref_pic_luma_pitch; 316bf215546Sopenharmony_ci uint32_t enc_ref_pic_chroma_pitch; 317bf215546Sopenharmony_ci uint32_t enc_ref_y_height_in_qw; 318bf215546Sopenharmony_ci uint32_t enc_ref_pic_addr_array_enc_pic_struct_restriction_disable_rdo; 319bf215546Sopenharmony_ci uint32_t enc_pre_encode_context_buffer_offset; 320bf215546Sopenharmony_ci uint32_t enc_pre_encode_input_luma_buffer_offset; 321bf215546Sopenharmony_ci uint32_t enc_pre_encode_input_chroma_buffer_offset; 322bf215546Sopenharmony_ci uint32_t enc_pre_encode_mode_chromaflag_vbaqmode_scenechangesensitivity; 323bf215546Sopenharmony_ci}; 324bf215546Sopenharmony_ci 325bf215546Sopenharmony_cistruct rvce_config_ext { 326bf215546Sopenharmony_ci uint32_t enc_enable_perf_logging; 327bf215546Sopenharmony_ci}; 328bf215546Sopenharmony_ci 329bf215546Sopenharmony_cistruct rvce_h264_enc_pic { 330bf215546Sopenharmony_ci struct rvce_rate_control rc; 331bf215546Sopenharmony_ci struct rvce_motion_estimation me; 332bf215546Sopenharmony_ci struct rvce_pic_control pc; 333bf215546Sopenharmony_ci struct rvce_task_info ti; 334bf215546Sopenharmony_ci struct rvce_feedback_buf_pkg fb; 335bf215546Sopenharmony_ci struct rvce_rdo rdo; 336bf215546Sopenharmony_ci struct rvce_vui vui; 337bf215546Sopenharmony_ci struct rvce_enc_operation eo; 338bf215546Sopenharmony_ci struct rvce_enc_create ec; 339bf215546Sopenharmony_ci struct rvce_config_ext ce; 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_ci unsigned quant_i_frames; 342bf215546Sopenharmony_ci unsigned quant_p_frames; 343bf215546Sopenharmony_ci unsigned quant_b_frames; 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ci enum pipe_h2645_enc_picture_type picture_type; 346bf215546Sopenharmony_ci unsigned frame_num; 347bf215546Sopenharmony_ci unsigned frame_num_cnt; 348bf215546Sopenharmony_ci unsigned p_remain; 349bf215546Sopenharmony_ci unsigned i_remain; 350bf215546Sopenharmony_ci unsigned idr_pic_id; 351bf215546Sopenharmony_ci unsigned gop_cnt; 352bf215546Sopenharmony_ci unsigned gop_size; 353bf215546Sopenharmony_ci unsigned pic_order_cnt; 354bf215546Sopenharmony_ci unsigned ref_idx_l0; 355bf215546Sopenharmony_ci unsigned ref_idx_l1; 356bf215546Sopenharmony_ci unsigned addrmode_arraymode_disrdo_distwoinstants; 357bf215546Sopenharmony_ci 358bf215546Sopenharmony_ci bool not_referenced; 359bf215546Sopenharmony_ci bool is_idr; 360bf215546Sopenharmony_ci bool has_ref_pic_list; 361bf215546Sopenharmony_ci bool enable_vui; 362bf215546Sopenharmony_ci unsigned int ref_pic_list_0[32]; 363bf215546Sopenharmony_ci unsigned int ref_pic_list_1[32]; 364bf215546Sopenharmony_ci unsigned int frame_idx[32]; 365bf215546Sopenharmony_ci}; 366bf215546Sopenharmony_ci 367bf215546Sopenharmony_ci/* VCE encoder representation */ 368bf215546Sopenharmony_cistruct rvce_encoder { 369bf215546Sopenharmony_ci struct pipe_video_codec base; 370bf215546Sopenharmony_ci 371bf215546Sopenharmony_ci /* version specific packets */ 372bf215546Sopenharmony_ci void (*session)(struct rvce_encoder *enc); 373bf215546Sopenharmony_ci void (*create)(struct rvce_encoder *enc); 374bf215546Sopenharmony_ci void (*feedback)(struct rvce_encoder *enc); 375bf215546Sopenharmony_ci void (*rate_control)(struct rvce_encoder *enc); 376bf215546Sopenharmony_ci void (*config_extension)(struct rvce_encoder *enc); 377bf215546Sopenharmony_ci void (*pic_control)(struct rvce_encoder *enc); 378bf215546Sopenharmony_ci void (*motion_estimation)(struct rvce_encoder *enc); 379bf215546Sopenharmony_ci void (*rdo)(struct rvce_encoder *enc); 380bf215546Sopenharmony_ci void (*vui)(struct rvce_encoder *enc); 381bf215546Sopenharmony_ci void (*config)(struct rvce_encoder *enc); 382bf215546Sopenharmony_ci void (*encode)(struct rvce_encoder *enc); 383bf215546Sopenharmony_ci void (*destroy)(struct rvce_encoder *enc); 384bf215546Sopenharmony_ci void (*task_info)(struct rvce_encoder *enc, uint32_t op, uint32_t dep, uint32_t fb_idx, 385bf215546Sopenharmony_ci uint32_t ring_idx); 386bf215546Sopenharmony_ci void (*si_get_pic_param)(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic); 387bf215546Sopenharmony_ci 388bf215546Sopenharmony_ci unsigned stream_handle; 389bf215546Sopenharmony_ci 390bf215546Sopenharmony_ci struct pipe_screen *screen; 391bf215546Sopenharmony_ci struct radeon_winsys *ws; 392bf215546Sopenharmony_ci struct radeon_cmdbuf cs; 393bf215546Sopenharmony_ci 394bf215546Sopenharmony_ci rvce_get_buffer get_buffer; 395bf215546Sopenharmony_ci 396bf215546Sopenharmony_ci struct pb_buffer *handle; 397bf215546Sopenharmony_ci struct radeon_surf *luma; 398bf215546Sopenharmony_ci struct radeon_surf *chroma; 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ci struct pb_buffer *bs_handle; 401bf215546Sopenharmony_ci unsigned bs_size; 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_ci struct rvce_cpb_slot *cpb_array; 404bf215546Sopenharmony_ci struct list_head cpb_slots; 405bf215546Sopenharmony_ci unsigned cpb_num; 406bf215546Sopenharmony_ci 407bf215546Sopenharmony_ci struct rvid_buffer *fb; 408bf215546Sopenharmony_ci struct rvid_buffer cpb; 409bf215546Sopenharmony_ci struct pipe_h264_enc_picture_desc pic; 410bf215546Sopenharmony_ci struct rvce_h264_enc_pic enc_pic; 411bf215546Sopenharmony_ci 412bf215546Sopenharmony_ci unsigned task_info_idx; 413bf215546Sopenharmony_ci unsigned bs_idx; 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_ci bool use_vm; 416bf215546Sopenharmony_ci bool use_vui; 417bf215546Sopenharmony_ci bool dual_pipe; 418bf215546Sopenharmony_ci bool dual_inst; 419bf215546Sopenharmony_ci}; 420bf215546Sopenharmony_ci 421bf215546Sopenharmony_ci/* CPB handling functions */ 422bf215546Sopenharmony_cistruct rvce_cpb_slot *si_current_slot(struct rvce_encoder *enc); 423bf215546Sopenharmony_cistruct rvce_cpb_slot *si_l0_slot(struct rvce_encoder *enc); 424bf215546Sopenharmony_cistruct rvce_cpb_slot *si_l1_slot(struct rvce_encoder *enc); 425bf215546Sopenharmony_civoid si_vce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, signed *luma_offset, 426bf215546Sopenharmony_ci signed *chroma_offset); 427bf215546Sopenharmony_ci 428bf215546Sopenharmony_cistruct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context, 429bf215546Sopenharmony_ci const struct pipe_video_codec *templat, 430bf215546Sopenharmony_ci struct radeon_winsys *ws, 431bf215546Sopenharmony_ci rvce_get_buffer get_buffer); 432bf215546Sopenharmony_ci 433bf215546Sopenharmony_cibool si_vce_is_fw_version_supported(struct si_screen *sscreen); 434bf215546Sopenharmony_ci 435bf215546Sopenharmony_civoid si_vce_add_buffer(struct rvce_encoder *enc, struct pb_buffer *buf, unsigned usage, 436bf215546Sopenharmony_ci enum radeon_bo_domain domain, signed offset); 437bf215546Sopenharmony_ci 438bf215546Sopenharmony_ci/* init vce fw 40.2.2 specific callbacks */ 439bf215546Sopenharmony_civoid si_vce_40_2_2_init(struct rvce_encoder *enc); 440bf215546Sopenharmony_ci 441bf215546Sopenharmony_ci/* init vce fw 50 specific callbacks */ 442bf215546Sopenharmony_civoid si_vce_50_init(struct rvce_encoder *enc); 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_ci/* init vce fw 52 specific callbacks */ 445bf215546Sopenharmony_civoid si_vce_52_init(struct rvce_encoder *enc); 446bf215546Sopenharmony_ci 447bf215546Sopenharmony_ci/* get parameters for vce 40.2.2 */ 448bf215546Sopenharmony_civoid si_vce_40_2_2_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic); 449bf215546Sopenharmony_ci 450bf215546Sopenharmony_ci/* get parameters for vce 50 */ 451bf215546Sopenharmony_civoid si_vce_50_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic); 452bf215546Sopenharmony_ci 453bf215546Sopenharmony_ci/* get parameters for vce 52 */ 454bf215546Sopenharmony_civoid si_vce_52_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic); 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ci#endif 457