brintos

brintos / linux-shallow public Read only

0
0
Text · 4.9 KiB · 889440a Raw
170 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright (c) 2016 MediaTek Inc.4 * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>5 *		Jungchang Tsao <jungchang.tsao@mediatek.com>6 *		Tiffany Lin <tiffany.lin@mediatek.com>7 */8 9#ifndef _VENC_DRV_IF_H_10#define _VENC_DRV_IF_H_11 12#include "mtk_vcodec_enc_drv.h"13 14/*15 * enum venc_yuv_fmt - The type of input yuv format16 * (VPU related: If you change the order, you must also update the VPU codes.)17 * @VENC_YUV_FORMAT_I420: I420 YUV format18 * @VENC_YUV_FORMAT_YV12: YV12 YUV format19 * @VENC_YUV_FORMAT_NV12: NV12 YUV format20 * @VENC_YUV_FORMAT_NV21: NV21 YUV format21 */22enum venc_yuv_fmt {23	VENC_YUV_FORMAT_I420 = 3,24	VENC_YUV_FORMAT_YV12 = 5,25	VENC_YUV_FORMAT_NV12 = 6,26	VENC_YUV_FORMAT_NV21 = 7,27};28 29/*30 * enum venc_start_opt - encode frame option used in venc_if_encode()31 * @VENC_START_OPT_ENCODE_SEQUENCE_HEADER: encode SPS/PPS for H26432 * @VENC_START_OPT_ENCODE_FRAME: encode normal frame33 */34enum venc_start_opt {35	VENC_START_OPT_ENCODE_SEQUENCE_HEADER,36	VENC_START_OPT_ENCODE_FRAME,37};38 39/*40 * enum venc_set_param_type - The type of set parameter used in41 *						      venc_if_set_param()42 * (VPU related: If you change the order, you must also update the VPU codes.)43 * @VENC_SET_PARAM_ENC: set encoder parameters44 * @VENC_SET_PARAM_FORCE_INTRA: force an intra frame45 * @VENC_SET_PARAM_ADJUST_BITRATE: adjust bitrate (in bps)46 * @VENC_SET_PARAM_ADJUST_FRAMERATE: set frame rate47 * @VENC_SET_PARAM_GOP_SIZE: set IDR interval48 * @VENC_SET_PARAM_INTRA_PERIOD: set I frame interval49 * @VENC_SET_PARAM_SKIP_FRAME: set H264 skip one frame50 * @VENC_SET_PARAM_PREPEND_HEADER: set H264 prepend SPS/PPS before IDR51 * @VENC_SET_PARAM_TS_MODE: set VP8 temporal scalability mode52 */53enum venc_set_param_type {54	VENC_SET_PARAM_ENC,55	VENC_SET_PARAM_FORCE_INTRA,56	VENC_SET_PARAM_ADJUST_BITRATE,57	VENC_SET_PARAM_ADJUST_FRAMERATE,58	VENC_SET_PARAM_GOP_SIZE,59	VENC_SET_PARAM_INTRA_PERIOD,60	VENC_SET_PARAM_SKIP_FRAME,61	VENC_SET_PARAM_PREPEND_HEADER,62	VENC_SET_PARAM_TS_MODE,63};64 65/*66 * struct venc_enc_prm - encoder settings for VENC_SET_PARAM_ENC used in67 *					  venc_if_set_param()68 * @input_fourcc: input yuv format69 * @h264_profile: V4L2 defined H.264 profile70 * @h264_level: V4L2 defined H.264 level71 * @width: image width72 * @height: image height73 * @buf_width: buffer width74 * @buf_height: buffer height75 * @frm_rate: frame rate in fps76 * @intra_period: intra frame period77 * @bitrate: target bitrate in bps78 * @gop_size: group of picture size79 */80struct venc_enc_param {81	enum venc_yuv_fmt input_yuv_fmt;82	unsigned int h264_profile;83	unsigned int h264_level;84	unsigned int width;85	unsigned int height;86	unsigned int buf_width;87	unsigned int buf_height;88	unsigned int frm_rate;89	unsigned int intra_period;90	unsigned int bitrate;91	unsigned int gop_size;92};93 94/**95 * struct venc_frame_info - per-frame information to pass to the firmware.96 *97 * @frm_count:		sequential number for this frame98 * @skip_frm_count:	number of frames skipped so far while decoding99 * @frm_type:		type of the frame, from enum venc_h264_frame_type100 */101struct venc_frame_info {102	unsigned int frm_count;		/* per frame update */103	unsigned int skip_frm_count;	/* per frame update */104	unsigned int frm_type;		/* per frame update */105};106 107/*108 * struct venc_frm_buf - frame buffer information used in venc_if_encode()109 * @fb_addr: plane frame buffer addresses110 */111struct venc_frm_buf {112	struct mtk_vcodec_fb fb_addr[MTK_VCODEC_MAX_PLANES];113};114 115/*116 * struct venc_done_result - This is return information used in venc_if_encode()117 * @bs_size: output bitstream size118 * @is_key_frm: output is key frame or not119 */120struct venc_done_result {121	unsigned int bs_size;122	bool is_key_frm;123};124 125extern const struct venc_common_if venc_h264_if;126extern const struct venc_common_if venc_vp8_if;127 128/*129 * venc_if_init - Create the driver handle130 * @ctx: device context131 * @fourcc: encoder input format132 * Return: 0 if creating handle successfully, otherwise it is failed.133 */134int venc_if_init(struct mtk_vcodec_enc_ctx *ctx, unsigned int fourcc);135 136/*137 * venc_if_deinit - Release the driver handle138 * @ctx: device context139 * Return: 0 if releasing handle successfully, otherwise it is failed.140 */141int venc_if_deinit(struct mtk_vcodec_enc_ctx *ctx);142 143/*144 * venc_if_set_param - Set parameter to driver145 * @ctx: device context146 * @type: parameter type147 * @in: input parameter148 * Return: 0 if setting param successfully, otherwise it is failed.149 */150int venc_if_set_param(struct mtk_vcodec_enc_ctx *ctx,151		      enum venc_set_param_type type,152		      struct venc_enc_param *in);153 154/*155 * venc_if_encode - Encode one frame156 * @ctx: device context157 * @opt: encode frame option158 * @frm_buf: input frame buffer information159 * @bs_buf: output bitstream buffer information160 * @result: encode result161 * Return: 0 if encoding frame successfully, otherwise it is failed.162 */163int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx,164		   enum venc_start_opt opt,165		   struct venc_frm_buf *frm_buf,166		   struct mtk_vcodec_mem *bs_buf,167		   struct venc_done_result *result);168 169#endif /* _VENC_DRV_IF_H_ */170