74 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright 2020-2021 NXP4 */5 6#ifndef _AMPHION_VPU_HELPERS_H7#define _AMPHION_VPU_HELPERS_H8 9struct vpu_pair {10 u32 src;11 u32 dst;12};13 14int vpu_helper_find_in_array_u8(const u8 *array, u32 size, u32 x);15bool vpu_helper_check_type(struct vpu_inst *inst, u32 type);16const struct vpu_format *vpu_helper_find_format(struct vpu_inst *inst, u32 type, u32 pixelfmt);17const struct vpu_format *vpu_helper_find_sibling(struct vpu_inst *inst, u32 type, u32 pixelfmt);18bool vpu_helper_match_format(struct vpu_inst *inst, u32 type, u32 fmta, u32 fmtb);19const struct vpu_format *vpu_helper_enum_format(struct vpu_inst *inst, u32 type, int index);20u32 vpu_helper_valid_frame_width(struct vpu_inst *inst, u32 width);21u32 vpu_helper_valid_frame_height(struct vpu_inst *inst, u32 height);22u32 vpu_helper_get_plane_size(u32 fmt, u32 width, u32 height, int plane_no,23 u32 stride, u32 interlaced, u32 *pbl);24int vpu_helper_copy_from_stream_buffer(struct vpu_buffer *stream_buffer,25 u32 *rptr, u32 size, void *dst);26int vpu_helper_copy_to_stream_buffer(struct vpu_buffer *stream_buffer,27 u32 *wptr, u32 size, void *src);28int vpu_helper_memset_stream_buffer(struct vpu_buffer *stream_buffer,29 u32 *wptr, u8 val, u32 size);30u32 vpu_helper_get_free_space(struct vpu_inst *inst);31u32 vpu_helper_get_used_space(struct vpu_inst *inst);32int vpu_helper_g_volatile_ctrl(struct v4l2_ctrl *ctrl);33void vpu_helper_get_kmp_next(const u8 *pattern, int *next, int size);34int vpu_helper_kmp_search(u8 *s, int s_len, const u8 *p, int p_len, int *next);35int vpu_helper_kmp_search_in_stream_buffer(struct vpu_buffer *stream_buffer,36 u32 offset, int bytesused,37 const u8 *p, int p_len, int *next);38int vpu_helper_find_startcode(struct vpu_buffer *stream_buffer,39 u32 pixelformat, u32 offset, u32 bytesused);40 41static inline u32 vpu_helper_step_walk(struct vpu_buffer *stream_buffer, u32 pos, u32 step)42{43 pos += step;44 if (pos > stream_buffer->phys + stream_buffer->length)45 pos -= stream_buffer->length;46 47 return pos;48}49 50static inline u8 vpu_helper_read_byte(struct vpu_buffer *stream_buffer, u32 pos)51{52 u8 *pdata = (u8 *)stream_buffer->virt;53 54 return pdata[pos % stream_buffer->length];55}56 57int vpu_color_check_primaries(u32 primaries);58int vpu_color_check_transfers(u32 transfers);59int vpu_color_check_matrix(u32 matrix);60int vpu_color_check_full_range(u32 full_range);61u32 vpu_color_cvrt_primaries_v2i(u32 primaries);62u32 vpu_color_cvrt_primaries_i2v(u32 primaries);63u32 vpu_color_cvrt_transfers_v2i(u32 transfers);64u32 vpu_color_cvrt_transfers_i2v(u32 transfers);65u32 vpu_color_cvrt_matrix_v2i(u32 matrix);66u32 vpu_color_cvrt_matrix_i2v(u32 matrix);67u32 vpu_color_cvrt_full_range_v2i(u32 full_range);68u32 vpu_color_cvrt_full_range_i2v(u32 full_range);69int vpu_color_get_default(u32 primaries, u32 *ptransfers, u32 *pmatrix, u32 *pfull_range);70 71int vpu_find_dst_by_src(struct vpu_pair *pairs, u32 cnt, u32 src);72int vpu_find_src_by_dst(struct vpu_pair *pairs, u32 cnt, u32 dst);73#endif74