File Index
Files and directories
Sign in
FILE

vpu_helpers.h

File preview with syntax highlighting.

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