From patchwork Tue Sep 8 12:32:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 249303 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4726750ilg; Tue, 8 Sep 2020 09:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvAfGoMlGFvvLOYTAg4NzA2oTJU63T+E8HkyvEuFyPgFR/HU6PMLx0927uHE3mhN6whLHp X-Received: by 2002:a50:e385:: with SMTP id b5mr20742161edm.39.1599584255069; Tue, 08 Sep 2020 09:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599584255; cv=none; d=google.com; s=arc-20160816; b=yyCtX0cy8cMHRSyDNMpdi1+M5t9VroeWJ7CtofPH1JNczqfheU1U/nugc7ozxi+q7z cEPvscR7HHKZPd+YksaX/gOpNnGBiFPWF7Kctjw+jmOwRz2swpGWcRmbKfiyfsJjog8E uFdESbhsmlLwi/PqeMmIs1qBc6fCxFIzxyCifM9iZ0U2zrQJG9c+fSnO9GWgxe03X6G9 5jzQc81/qH8ZcOwygZtGhY2HtbhqsEvyBX5j75DhMkqOazBKCj4Q0MEhJIWskJ3+Lmyv vydAP6rBeCDNB/i3CHeOZBLK6T8nRIR1//iuUcxW0lnUI0uRq1OAoi7H4Ur09YAh0D5C ueTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=07BSV6FZ4poiSm+/jd7LwQlNgIEpEAXaLzeC1JvctXE=; b=QWzwiQpSQiM3UtuB38eeuOtUIqFCwQKk+JmucS64jF7GJfVyxxBvnP4aHm1+f8xfMH HRJswAZpzujf4ILXJizQAOluqyDCxZ20MXm6uO5e4Es/kliHw6fZ6JvJ9qH4/NBWsIF3 HDrjLxTZG7VycvWXR71a4b+weq/7U1UB8Is7TjRpYMai5BGye+je3/YoLRzzMFHroqHm ZGpt42D6/yGa6H86G0AfoJr3PBuj475MBWb5giUPNTRUwLqc1cTzPlC5zmVPyi7/a7sI WRbbED1u2qr2tBDGXjlgOy5C1mPsr83fa6Tle5ar+Ts7TS6cAOOz4Iq8uVoxWaapwuxD uuCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SMnPVAVq; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p61si6094951edd.188.2020.09.08.09.57.34; Tue, 08 Sep 2020 09:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SMnPVAVq; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731807AbgIHQ5c (ORCPT + 15 others); Tue, 8 Sep 2020 12:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730701AbgIHQ5M (ORCPT ); Tue, 8 Sep 2020 12:57:12 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2B2C061359 for ; Tue, 8 Sep 2020 05:33:40 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id n13so15789604edo.10 for ; Tue, 08 Sep 2020 05:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=07BSV6FZ4poiSm+/jd7LwQlNgIEpEAXaLzeC1JvctXE=; b=SMnPVAVq+CNLCQ0T1LSMvvpTkQRhfvdC957DRxw55JGRxDy5/pS2LaaThhquaUeRgM WT0sbDcx7fSYus/UO1AvvQosPZ0EcmhZuOnInyVngJ/1/+16lk5G/xTyvSpGmuyFw0kP z0wvXwOtokUqe+li/riRJvOUQ1GkXVF7mJShxVUPHps33vmyLliIi341pj2pw7U/1U08 eVWq/GTiJFsUVybw3vTBvXwyNE3w9pNuqW94qCtkFUZDG8an5lFUTOuwoB/3LqE+LbYF LXJmvjlJXYSq+12BX2+o0TnlANatNc0GXbdeF8ZLxNTDlfSetrbq11lKZH/PbAclQhli ouKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=07BSV6FZ4poiSm+/jd7LwQlNgIEpEAXaLzeC1JvctXE=; b=qBnGcYr7jSebwmHXLSwVddv78m948jkunpVjeFHo2hVMIJDW92JPz8HU1Og2+iZgNi PQWUyV+zS6WNkLtPV9gDwCin4S9sM6tRECTFjXpOVkAvEPM1SegJKwz8fQ0y7rpaw0NZ 9ipjfmoMB75Sg6BMx/nJNnJ+hBnWPRGQuGnTpDKV98fj2jrTqKmAg7VlpIOLfRLqq0kN MAXklxMb6w/5gWg1PZ0f5YgMNBHdyroEhWswACgAbzlmVyD6LC8G9ebAsbQbUAmOBCjH qobMZaE/6zoS3ZUvidNaEmawGYpUy93SEAO+fDIzhDyCUBpuNyfC8RXddS/FQHmPvfFD Rn6A== X-Gm-Message-State: AOAM530bkzCVTOmKkXrijxVwGWKcvafP9WXLZxyJCMNcm2dDb5s2n67I txH6kC4rEJtWTDz0jbUxZFDPj7CCUuZxdSqO X-Received: by 2002:a50:ee14:: with SMTP id g20mr15064878eds.32.1599568419058; Tue, 08 Sep 2020 05:33:39 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id y9sm17499744edo.37.2020.09.08.05.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 05:33:38 -0700 (PDT) From: Stanimir Varbanov To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Paul Kocialkowski , Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab , Neil Armstrong , nicolas.dufresne@collabora.com, Stanimir Varbanov Subject: [PATCH v3 6/6] venus: venc: Use helper to set profile and level Date: Tue, 8 Sep 2020 15:32:21 +0300 Message-Id: <20200908123221.2793-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200908123221.2793-1-stanimir.varbanov@linaro.org> References: <20200908123221.2793-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org We have a new helper to set profile and level use it instead. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 13 +- drivers/media/platform/qcom/venus/venc.c | 159 +----------------- .../media/platform/qcom/venus/venc_ctrls.c | 14 +- 3 files changed, 6 insertions(+), 180 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 1a7aee7ee628..2e70004ef195 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -239,17 +239,8 @@ struct venc_controls { u32 header_mode; - struct { - u32 mpeg4; - u32 h264; - u32 vpx; - u32 hevc; - } profile; - struct { - u32 mpeg4; - u32 h264; - u32 hevc; - } level; + u32 profile; + u32 level; }; struct venus_buffer { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 6b758a33397e..f8b1484e7dcd 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -113,80 +113,6 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type) static int venc_v4l2_to_hfi(int id, int value) { switch (id) { - case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: - switch (value) { - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_0: - default: - return HFI_MPEG4_LEVEL_0; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B: - return HFI_MPEG4_LEVEL_0b; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_1: - return HFI_MPEG4_LEVEL_1; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_2: - return HFI_MPEG4_LEVEL_2; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_3: - return HFI_MPEG4_LEVEL_3; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_4: - return HFI_MPEG4_LEVEL_4; - case V4L2_MPEG_VIDEO_MPEG4_LEVEL_5: - return HFI_MPEG4_LEVEL_5; - } - case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: - switch (value) { - case V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE: - default: - return HFI_MPEG4_PROFILE_SIMPLE; - case V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE: - return HFI_MPEG4_PROFILE_ADVANCEDSIMPLE; - } - case V4L2_CID_MPEG_VIDEO_H264_PROFILE: - switch (value) { - case V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE: - return HFI_H264_PROFILE_BASELINE; - case V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE: - return HFI_H264_PROFILE_CONSTRAINED_BASE; - case V4L2_MPEG_VIDEO_H264_PROFILE_MAIN: - return HFI_H264_PROFILE_MAIN; - case V4L2_MPEG_VIDEO_H264_PROFILE_HIGH: - default: - return HFI_H264_PROFILE_HIGH; - } - case V4L2_CID_MPEG_VIDEO_H264_LEVEL: - switch (value) { - case V4L2_MPEG_VIDEO_H264_LEVEL_1_0: - return HFI_H264_LEVEL_1; - case V4L2_MPEG_VIDEO_H264_LEVEL_1B: - return HFI_H264_LEVEL_1b; - case V4L2_MPEG_VIDEO_H264_LEVEL_1_1: - return HFI_H264_LEVEL_11; - case V4L2_MPEG_VIDEO_H264_LEVEL_1_2: - return HFI_H264_LEVEL_12; - case V4L2_MPEG_VIDEO_H264_LEVEL_1_3: - return HFI_H264_LEVEL_13; - case V4L2_MPEG_VIDEO_H264_LEVEL_2_0: - return HFI_H264_LEVEL_2; - case V4L2_MPEG_VIDEO_H264_LEVEL_2_1: - return HFI_H264_LEVEL_21; - case V4L2_MPEG_VIDEO_H264_LEVEL_2_2: - return HFI_H264_LEVEL_22; - case V4L2_MPEG_VIDEO_H264_LEVEL_3_0: - return HFI_H264_LEVEL_3; - case V4L2_MPEG_VIDEO_H264_LEVEL_3_1: - return HFI_H264_LEVEL_31; - case V4L2_MPEG_VIDEO_H264_LEVEL_3_2: - return HFI_H264_LEVEL_32; - case V4L2_MPEG_VIDEO_H264_LEVEL_4_0: - return HFI_H264_LEVEL_4; - case V4L2_MPEG_VIDEO_H264_LEVEL_4_1: - return HFI_H264_LEVEL_41; - case V4L2_MPEG_VIDEO_H264_LEVEL_4_2: - return HFI_H264_LEVEL_42; - case V4L2_MPEG_VIDEO_H264_LEVEL_5_0: - default: - return HFI_H264_LEVEL_5; - case V4L2_MPEG_VIDEO_H264_LEVEL_5_1: - return HFI_H264_LEVEL_51; - } case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: switch (value) { case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC: @@ -195,18 +121,6 @@ static int venc_v4l2_to_hfi(int id, int value) case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC: return HFI_H264_ENTROPY_CABAC; } - case V4L2_CID_MPEG_VIDEO_VP8_PROFILE: - switch (value) { - case 0: - default: - return HFI_VPX_PROFILE_VERSION_0; - case 1: - return HFI_VPX_PROFILE_VERSION_1; - case 2: - return HFI_VPX_PROFILE_VERSION_2; - case 3: - return HFI_VPX_PROFILE_VERSION_3; - } case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: switch (value) { case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED: @@ -217,46 +131,6 @@ static int venc_v4l2_to_hfi(int id, int value) case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY: return HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY; } - case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE: - switch (value) { - case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN: - default: - return HFI_HEVC_PROFILE_MAIN; - case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE: - return HFI_HEVC_PROFILE_MAIN_STILL_PIC; - case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10: - return HFI_HEVC_PROFILE_MAIN10; - } - case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: - switch (value) { - case V4L2_MPEG_VIDEO_HEVC_LEVEL_1: - default: - return HFI_HEVC_LEVEL_1; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_2: - return HFI_HEVC_LEVEL_2; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1: - return HFI_HEVC_LEVEL_21; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_3: - return HFI_HEVC_LEVEL_3; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1: - return HFI_HEVC_LEVEL_31; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_4: - return HFI_HEVC_LEVEL_4; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1: - return HFI_HEVC_LEVEL_41; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_5: - return HFI_HEVC_LEVEL_5; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1: - return HFI_HEVC_LEVEL_51; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2: - return HFI_HEVC_LEVEL_52; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_6: - return HFI_HEVC_LEVEL_6; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1: - return HFI_HEVC_LEVEL_61; - case V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2: - return HFI_HEVC_LEVEL_62; - } } return 0; @@ -657,13 +531,12 @@ static int venc_set_properties(struct venus_inst *inst) { struct venc_controls *ctr = &inst->controls.enc; struct hfi_intra_period intra_period; - struct hfi_profile_level pl; struct hfi_framerate frate; struct hfi_bitrate brate; struct hfi_idr_period idrp; struct hfi_quantization quant; struct hfi_quantization_range quant_range; - u32 ptype, rate_control, bitrate, profile = 0, level = 0; + u32 ptype, rate_control, bitrate; int ret; ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); @@ -811,35 +684,7 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; - if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { - profile = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_H264_PROFILE, - ctr->profile.h264); - level = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_H264_LEVEL, - ctr->level.h264); - } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_VP8) { - profile = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_VP8_PROFILE, - ctr->profile.vpx); - level = 0; - } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_MPEG4) { - profile = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE, - ctr->profile.mpeg4); - level = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL, - ctr->level.mpeg4); - } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H263) { - profile = 0; - level = 0; - } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { - profile = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_HEVC_PROFILE, - ctr->profile.hevc); - level = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_HEVC_LEVEL, - ctr->level.hevc); - } - - ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; - pl.profile = profile; - pl.level = level; - - ret = hfi_session_set_property(inst, ptype, &pl); + ret = venus_helper_set_profile_level(inst, ctr->profile, ctr->level); if (ret) return ret; diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index 22a7c045c6a9..0708b3b89d0c 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -103,25 +103,15 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ctr->h264_entropy_mode = ctrl->val; break; case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: - ctr->profile.mpeg4 = ctrl->val; - break; case V4L2_CID_MPEG_VIDEO_H264_PROFILE: - ctr->profile.h264 = ctrl->val; - break; case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE: - ctr->profile.hevc = ctrl->val; - break; case V4L2_CID_MPEG_VIDEO_VP8_PROFILE: - ctr->profile.vpx = ctrl->val; + ctr->profile = ctrl->val; break; case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: - ctr->level.mpeg4 = ctrl->val; - break; case V4L2_CID_MPEG_VIDEO_H264_LEVEL: - ctr->level.h264 = ctrl->val; - break; case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: - ctr->level.hevc = ctrl->val; + ctr->level = ctrl->val; break; case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: ctr->h264_i_qp = ctrl->val;