summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/qcom/venus/hfi_parser.h
blob: 3e931c747e19b8da23db7b021f1ef8275200debf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2018 Linaro Ltd. */
#ifndef __VENUS_HFI_PARSER_H__
#define __VENUS_HFI_PARSER_H__

#include "core.h"

u32 hfi_parser(struct venus_core *core, struct venus_inst *inst,
	       void *buf, u32 size);

#define WHICH_CAP_MIN	0
#define WHICH_CAP_MAX	1
#define WHICH_CAP_STEP	2

static inline u32 get_cap(struct venus_inst *inst, u32 type, u32 which)
{
	struct venus_core *core = inst->core;
	struct hfi_capability *cap = NULL;
	struct venus_caps *caps;
	unsigned int i;

	caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type);
	if (!caps)
		return 0;

	for (i = 0; i < caps->num_caps; i++) {
		if (caps->caps[i].capability_type == type) {
			cap = &caps->caps[i];
			break;
		}
	}

	if (!cap)
		return 0;

	switch (which) {
	case WHICH_CAP_MIN:
		return cap->min;
	case WHICH_CAP_MAX:
		return cap->max;
	case WHICH_CAP_STEP:
		return cap->step_size;
	default:
		break;
	}

	return 0;
}

static inline u32 cap_min(struct venus_inst *inst, u32 type)
{
	return get_cap(inst, type, WHICH_CAP_MIN);
}

static inline u32 cap_max(struct venus_inst *inst, u32 type)
{
	return get_cap(inst, type, WHICH_CAP_MAX);
}

static inline u32 cap_step(struct venus_inst *inst, u32 type)
{
	return get_cap(inst, type, WHICH_CAP_STEP);
}

static inline u32 frame_width_min(struct venus_inst *inst)
{
	return cap_min(inst, HFI_CAPABILITY_FRAME_WIDTH);
}

static inline u32 frame_width_max(struct venus_inst *inst)
{
	return cap_max(inst, HFI_CAPABILITY_FRAME_WIDTH);
}

static inline u32 frame_width_step(struct venus_inst *inst)
{
	return cap_step(inst, HFI_CAPABILITY_FRAME_WIDTH);
}

static inline u32 frame_height_min(struct venus_inst *inst)
{
	return cap_min(inst, HFI_CAPABILITY_FRAME_HEIGHT);
}

static inline u32 frame_height_max(struct venus_inst *inst)
{
	return cap_max(inst, HFI_CAPABILITY_FRAME_HEIGHT);
}

static inline u32 frame_height_step(struct venus_inst *inst)
{
	return cap_step(inst, HFI_CAPABILITY_FRAME_HEIGHT);
}

static inline u32 frate_min(struct venus_inst *inst)
{
	return cap_min(inst, HFI_CAPABILITY_FRAMERATE);
}

static inline u32 frate_max(struct venus_inst *inst)
{
	return cap_max(inst, HFI_CAPABILITY_FRAMERATE);
}

static inline u32 frate_step(struct venus_inst *inst)
{
	return cap_step(inst, HFI_CAPABILITY_FRAMERATE);
}

#endif