1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 */ 5 6 #ifndef __IRIS_INSTANCE_H__ 7 #define __IRIS_INSTANCE_H__ 8 9 #include <media/v4l2-ctrls.h> 10 11 #include "iris_buffer.h" 12 #include "iris_core.h" 13 #include "iris_utils.h" 14 15 #define DEFAULT_WIDTH 320 16 #define DEFAULT_HEIGHT 240 17 18 enum iris_fmt_type_out { 19 IRIS_FMT_H264, 20 IRIS_FMT_HEVC, 21 IRIS_FMT_VP9, 22 IRIS_FMT_AV1, 23 }; 24 25 enum iris_fmt_type_cap { 26 IRIS_FMT_NV12, 27 IRIS_FMT_QC08C, 28 }; 29 30 struct iris_fmt { 31 u32 pixfmt; 32 u32 type; 33 }; 34 35 /** 36 * struct iris_inst - holds per video instance parameters 37 * 38 * @list: used for attach an instance to the core 39 * @core: pointer to core structure 40 * @session_id: id of current video session 41 * @ctx_q_lock: lock to serialize queues related ioctls 42 * @lock: lock to seralise forward and reverse threads 43 * @fh: reference of v4l2 file handler 44 * @fmt_src: structure of v4l2_format for source 45 * @fmt_dst: structure of v4l2_format for destination 46 * @ctrl_handler: reference of v4l2 ctrl handler 47 * @domain: domain type: encoder or decoder 48 * @crop: structure of crop info 49 * @compose: structure of compose info 50 * @completion: structure of signal completions 51 * @flush_completion: structure of signal completions for flush cmd 52 * @flush_responses_pending: counter to track number of pending flush responses 53 * @fw_caps: array of supported instance firmware capabilities 54 * @buffers: array of different iris buffers 55 * @fw_min_count: minimnum count of buffers needed by fw 56 * @state: instance state 57 * @sub_state: instance sub state 58 * @once_per_session_set: boolean to set once per session property 59 * @max_input_data_size: max size of input data 60 * @power: structure of power info 61 * @icc_data: structure of interconnect data 62 * @m2m_dev: a reference to m2m device structure 63 * @m2m_ctx: a reference to m2m context structure 64 * @sequence_cap: a sequence counter for capture queue 65 * @sequence_out: a sequence counter for output queue 66 * @tss: timestamp metadata 67 * @metadata_idx: index for metadata buffer 68 * @codec: codec type 69 * @last_buffer_dequeued: a flag to indicate that last buffer is sent by driver 70 * @frame_rate: frame rate of current instance 71 * @operating_rate: operating rate of current instance 72 * @hfi_rc_type: rate control type 73 * @enc_raw_width: source image width for encoder instance 74 * @enc_raw_height: source image height for encoder instance 75 * @enc_scale_width: scale width for encoder instance 76 * @enc_scale_height: scale height for encoder instance 77 */ 78 79 struct iris_inst { 80 struct list_head list; 81 struct iris_core *core; 82 u32 session_id; 83 struct mutex ctx_q_lock;/* lock to serialize queues related ioctls */ 84 struct mutex lock; /* lock to serialize forward and reverse threads */ 85 struct v4l2_fh fh; 86 struct v4l2_format *fmt_src; 87 struct v4l2_format *fmt_dst; 88 struct v4l2_ctrl_handler ctrl_handler; 89 enum domain_type domain; 90 struct iris_hfi_rect_desc crop; 91 struct iris_hfi_rect_desc compose; 92 struct completion completion; 93 struct completion flush_completion; 94 u32 flush_responses_pending; 95 struct platform_inst_fw_cap fw_caps[INST_FW_CAP_MAX]; 96 struct iris_buffers buffers[BUF_TYPE_MAX]; 97 u32 fw_min_count; 98 enum iris_inst_state state; 99 enum iris_inst_sub_state sub_state; 100 bool once_per_session_set; 101 size_t max_input_data_size; 102 struct iris_inst_power power; 103 struct icc_vote_data icc_data; 104 struct v4l2_m2m_dev *m2m_dev; 105 struct v4l2_m2m_ctx *m2m_ctx; 106 u32 sequence_cap; 107 u32 sequence_out; 108 struct iris_ts_metadata tss[VIDEO_MAX_FRAME]; 109 u32 metadata_idx; 110 u32 codec; 111 bool last_buffer_dequeued; 112 u32 frame_rate; 113 u32 operating_rate; 114 u32 hfi_rc_type; 115 u32 enc_raw_width; 116 u32 enc_raw_height; 117 u32 enc_scale_width; 118 u32 enc_scale_height; 119 }; 120 121 #endif 122