| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. |
|---|
| 3 | 4 | * Copyright (C) 2017 Linaro Ltd. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License version 2 and |
|---|
| 7 | | - * only version 2 as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | #include <linux/types.h> |
|---|
| 16 | 7 | #include <media/v4l2-ctrls.h> |
|---|
| 17 | 8 | |
|---|
| 18 | 9 | #include "core.h" |
|---|
| 10 | +#include "helpers.h" |
|---|
| 19 | 11 | #include "vdec.h" |
|---|
| 20 | 12 | |
|---|
| 21 | 13 | static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) |
|---|
| .. | .. |
|---|
| 30 | 22 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: |
|---|
| 31 | 23 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: |
|---|
| 32 | 24 | case V4L2_CID_MPEG_VIDEO_VP8_PROFILE: |
|---|
| 25 | + case V4L2_CID_MPEG_VIDEO_VP9_PROFILE: |
|---|
| 33 | 26 | ctr->profile = ctrl->val; |
|---|
| 34 | 27 | break; |
|---|
| 35 | 28 | case V4L2_CID_MPEG_VIDEO_H264_LEVEL: |
|---|
| 36 | 29 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: |
|---|
| 30 | + case V4L2_CID_MPEG_VIDEO_VP9_LEVEL: |
|---|
| 37 | 31 | ctr->level = ctrl->val; |
|---|
| 38 | 32 | break; |
|---|
| 39 | 33 | default: |
|---|
| .. | .. |
|---|
| 47 | 41 | { |
|---|
| 48 | 42 | struct venus_inst *inst = ctrl_to_inst(ctrl); |
|---|
| 49 | 43 | struct vdec_controls *ctr = &inst->controls.dec; |
|---|
| 50 | | - union hfi_get_property hprop; |
|---|
| 51 | | - u32 ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; |
|---|
| 44 | + struct hfi_buffer_requirements bufreq; |
|---|
| 45 | + enum hfi_version ver = inst->core->res->hfi_version; |
|---|
| 46 | + u32 profile, level; |
|---|
| 52 | 47 | int ret; |
|---|
| 53 | 48 | |
|---|
| 54 | 49 | switch (ctrl->id) { |
|---|
| 55 | 50 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: |
|---|
| 56 | 51 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: |
|---|
| 57 | 52 | case V4L2_CID_MPEG_VIDEO_VP8_PROFILE: |
|---|
| 58 | | - ret = hfi_session_get_property(inst, ptype, &hprop); |
|---|
| 53 | + case V4L2_CID_MPEG_VIDEO_VP9_PROFILE: |
|---|
| 54 | + ret = venus_helper_get_profile_level(inst, &profile, &level); |
|---|
| 59 | 55 | if (!ret) |
|---|
| 60 | | - ctr->profile = hprop.profile_level.profile; |
|---|
| 56 | + ctr->profile = profile; |
|---|
| 61 | 57 | ctrl->val = ctr->profile; |
|---|
| 62 | 58 | break; |
|---|
| 63 | 59 | case V4L2_CID_MPEG_VIDEO_H264_LEVEL: |
|---|
| 64 | 60 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: |
|---|
| 65 | | - ret = hfi_session_get_property(inst, ptype, &hprop); |
|---|
| 61 | + case V4L2_CID_MPEG_VIDEO_VP9_LEVEL: |
|---|
| 62 | + ret = venus_helper_get_profile_level(inst, &profile, &level); |
|---|
| 66 | 63 | if (!ret) |
|---|
| 67 | | - ctr->level = hprop.profile_level.level; |
|---|
| 64 | + ctr->level = level; |
|---|
| 68 | 65 | ctrl->val = ctr->level; |
|---|
| 69 | 66 | break; |
|---|
| 70 | 67 | case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: |
|---|
| 71 | 68 | ctrl->val = ctr->post_loop_deb_mode; |
|---|
| 72 | 69 | break; |
|---|
| 73 | 70 | case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: |
|---|
| 74 | | - ctrl->val = inst->num_output_bufs; |
|---|
| 71 | + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); |
|---|
| 72 | + if (!ret) |
|---|
| 73 | + ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); |
|---|
| 75 | 74 | break; |
|---|
| 76 | 75 | default: |
|---|
| 77 | 76 | return -EINVAL; |
|---|
| 78 | | - }; |
|---|
| 77 | + } |
|---|
| 79 | 78 | |
|---|
| 80 | 79 | return 0; |
|---|
| 81 | 80 | } |
|---|
| .. | .. |
|---|
| 90 | 89 | struct v4l2_ctrl *ctrl; |
|---|
| 91 | 90 | int ret; |
|---|
| 92 | 91 | |
|---|
| 93 | | - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 7); |
|---|
| 92 | + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 9); |
|---|
| 94 | 93 | if (ret) |
|---|
| 95 | 94 | return ret; |
|---|
| 96 | 95 | |
|---|
| .. | .. |
|---|
| 137 | 136 | if (ctrl) |
|---|
| 138 | 137 | ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; |
|---|
| 139 | 138 | |
|---|
| 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); |
|---|
| 143 | + if (ctrl) |
|---|
| 144 | + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; |
|---|
| 145 | + |
|---|
| 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); |
|---|
| 150 | + if (ctrl) |
|---|
| 151 | + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; |
|---|
| 152 | + |
|---|
| 140 | 153 | v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, |
|---|
| 141 | 154 | V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER, 0, 1, 1, 0); |
|---|
| 142 | 155 | |
|---|