1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2017 Linaro Ltd.
6 #include <linux/types.h>
7 #include <media/v4l2-ctrls.h>
13 static int vdec_op_s_ctrl(struct v4l2_ctrl
*ctrl
)
15 struct venus_inst
*inst
= ctrl_to_inst(ctrl
);
16 struct vdec_controls
*ctr
= &inst
->controls
.dec
;
19 case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER
:
20 ctr
->post_loop_deb_mode
= ctrl
->val
;
22 case V4L2_CID_MPEG_VIDEO_H264_PROFILE
:
23 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE
:
24 case V4L2_CID_MPEG_VIDEO_VP8_PROFILE
:
25 case V4L2_CID_MPEG_VIDEO_VP9_PROFILE
:
26 ctr
->profile
= ctrl
->val
;
28 case V4L2_CID_MPEG_VIDEO_H264_LEVEL
:
29 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL
:
30 case V4L2_CID_MPEG_VIDEO_VP9_LEVEL
:
31 ctr
->level
= ctrl
->val
;
40 static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl
*ctrl
)
42 struct venus_inst
*inst
= ctrl_to_inst(ctrl
);
43 struct vdec_controls
*ctr
= &inst
->controls
.dec
;
44 struct hfi_buffer_requirements bufreq
;
45 enum hfi_version ver
= inst
->core
->res
->hfi_version
;
50 case V4L2_CID_MPEG_VIDEO_H264_PROFILE
:
51 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE
:
52 case V4L2_CID_MPEG_VIDEO_VP8_PROFILE
:
53 case V4L2_CID_MPEG_VIDEO_VP9_PROFILE
:
54 ret
= venus_helper_get_profile_level(inst
, &profile
, &level
);
56 ctr
->profile
= profile
;
57 ctrl
->val
= ctr
->profile
;
59 case V4L2_CID_MPEG_VIDEO_H264_LEVEL
:
60 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL
:
61 case V4L2_CID_MPEG_VIDEO_VP9_LEVEL
:
62 ret
= venus_helper_get_profile_level(inst
, &profile
, &level
);
65 ctrl
->val
= ctr
->level
;
67 case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER
:
68 ctrl
->val
= ctr
->post_loop_deb_mode
;
70 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE
:
71 ret
= venus_helper_get_bufreq(inst
, HFI_BUFFER_OUTPUT
, &bufreq
);
73 ctrl
->val
= HFI_BUFREQ_COUNT_MIN(&bufreq
, ver
);
82 static const struct v4l2_ctrl_ops vdec_ctrl_ops
= {
83 .s_ctrl
= vdec_op_s_ctrl
,
84 .g_volatile_ctrl
= vdec_op_g_volatile_ctrl
,
87 int vdec_ctrl_init(struct venus_inst
*inst
)
89 struct v4l2_ctrl
*ctrl
;
92 ret
= v4l2_ctrl_handler_init(&inst
->ctrl_handler
, 9);
96 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
97 V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE
,
98 V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY
,
99 ~((1 << V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE
) |
100 (1 << V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE
)),
101 V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE
);
103 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
105 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
106 V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL
,
107 V4L2_MPEG_VIDEO_MPEG4_LEVEL_5
,
108 0, V4L2_MPEG_VIDEO_MPEG4_LEVEL_0
);
110 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
112 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
113 V4L2_CID_MPEG_VIDEO_H264_PROFILE
,
114 V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH
,
115 ~((1 << V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE
) |
116 (1 << V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE
) |
117 (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MAIN
) |
118 (1 << V4L2_MPEG_VIDEO_H264_PROFILE_HIGH
) |
119 (1 << V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH
) |
120 (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH
)),
121 V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE
);
123 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
125 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
126 V4L2_CID_MPEG_VIDEO_H264_LEVEL
,
127 V4L2_MPEG_VIDEO_H264_LEVEL_5_1
,
128 0, V4L2_MPEG_VIDEO_H264_LEVEL_1_0
);
130 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
132 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
133 V4L2_CID_MPEG_VIDEO_VP8_PROFILE
,
134 V4L2_MPEG_VIDEO_VP8_PROFILE_3
,
135 0, V4L2_MPEG_VIDEO_VP8_PROFILE_0
);
137 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
139 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
140 V4L2_CID_MPEG_VIDEO_VP9_PROFILE
,
141 V4L2_MPEG_VIDEO_VP9_PROFILE_3
,
142 0, V4L2_MPEG_VIDEO_VP9_PROFILE_0
);
144 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
146 ctrl
= v4l2_ctrl_new_std_menu(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
147 V4L2_CID_MPEG_VIDEO_VP9_LEVEL
,
148 V4L2_MPEG_VIDEO_VP9_LEVEL_6_2
,
149 0, V4L2_MPEG_VIDEO_VP9_LEVEL_1_0
);
151 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
153 v4l2_ctrl_new_std(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
154 V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER
, 0, 1, 1, 0);
156 ctrl
= v4l2_ctrl_new_std(&inst
->ctrl_handler
, &vdec_ctrl_ops
,
157 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE
, 1, 32, 1, 1);
159 ctrl
->flags
|= V4L2_CTRL_FLAG_VOLATILE
;
161 ret
= inst
->ctrl_handler
.error
;
163 v4l2_ctrl_handler_free(&inst
->ctrl_handler
);
170 void vdec_ctrl_deinit(struct venus_inst
*inst
)
172 v4l2_ctrl_handler_free(&inst
->ctrl_handler
);