Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4459828rwd; Tue, 30 May 2023 05:53:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XX6QW7Ge8ZoOxq1e6aRb/8qcbbnsZG+RzgEvtk0Qin54Y40IdvMP0OK8k4QwZ2AvFWbX3 X-Received: by 2002:a17:902:e548:b0:1ab:1624:38cf with SMTP id n8-20020a170902e54800b001ab162438cfmr2730057plf.60.1685451196266; Tue, 30 May 2023 05:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685451196; cv=none; d=google.com; s=arc-20160816; b=Yor55N48m1t6mEIftvxlxrnI40puPuTu3RUEW/xJXromgT+/rzFO6LeKfRVsArn/0S I1MIb8sefUFeA7WbVxmJ1kqMfI+64lupCk10RD+M2ymI1QLUcE4rbp9ca4IilHzqBrbR xUskCml+FnbDgaNQuimJ5PsNkt0/r5wuoOiau1pS6Dil+t2SHHAOF6UxLut3K1SwDLuJ 0Mva0o1UbYpzwZyXCTuik/V5/MDQ2yQyyeoqhVmMigjnbr/bu8YUOSSD2Ie9sWPMnH1y G31qwWiL2BZNrTOOLQVGlCl4WnuPDvwHxp7cSQSWfZqrJk/jCY/jZx+YQCZ4V6SGHHXH J+bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=fysaOYiCjviYo83FWRPC+oME16aSTNADlHkhbO2qk9Y=; b=b/Oau/VL3baE2G8ABHlbX87UDNbdABgyXUiTOf7IEDjYnOoENJxBgeZVxEBqcOVzkX HObJrHK/fSj5d7TfBMSHz9VFs5r3CTdybwRkfPBC+2Z/iykh6ToPSOkQgB9Q4dL/TMqr REzrrFPfTemjXIADC+5UvT9A5qQMeJe1Fukwfyj1SIhSldzn0fUcUSSj64Y/oCf8al64 decOpYQtYI647BfuZ8oiRMDr/766N+MPTj5m/DQBeOwv4g3iMzlbxIplBZhBgMSvW8ip fW5dOmyzn/mvpB7c2QmlhgjqmwxSYAHSs24Y6yjdskpBtg8UzKmpxux+NO4haSF+EEOa lJyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TMi1Z8Rv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a170902b70800b001b046c37589si2959787pls.428.2023.05.30.05.53.03; Tue, 30 May 2023 05:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TMi1Z8Rv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S230501AbjE3MdD (ORCPT + 99 others); Tue, 30 May 2023 08:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjE3Mcc (ORCPT ); Tue, 30 May 2023 08:32:32 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6597D1BF for ; Tue, 30 May 2023 05:31:57 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2af98eb6ef0so47169231fa.3 for ; Tue, 30 May 2023 05:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685449861; x=1688041861; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fysaOYiCjviYo83FWRPC+oME16aSTNADlHkhbO2qk9Y=; b=TMi1Z8RvFyyvaVXE2GBU76CzOngLAQnbnL1weWU21JeGcVhlw2N+g6FXtyXhYC1Kxg k4mp5REQNtrvMkDxbJI/EHklFm2SHxIPhiiZxjt5gkaYCBar3Mz1aV/8oSapunVT61KD 7gT0W3K9+OPVM3nAsZG+gBjeQBfRP0rijsF9RLe68PET7d1ZBuImHjhIKfqXqqZZAP3Q iiZVLAAminVAYskLLVKWkh4ZLDTysLcmV2uLYoAAcZ0HC3JXWjzkXOoFKbakaqUUFIDt Y2bt0cyNQ4GzluW3lXdDrOMGIvreh9g8l9D+1BEIRmxNej5BFNocKrNYmXTYSDA/hMAm ZNbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685449861; x=1688041861; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fysaOYiCjviYo83FWRPC+oME16aSTNADlHkhbO2qk9Y=; b=UJf7VjQEpDk242BrKOZ51HgFyKa+s+02LgsmICdMFZEnMZRdK3NMYqjn3a3k/xNspy oblEvIFvht/WxHLd58WjGBbZN5EgI0UvgEuvO6ligEHbZe0ZTqFflKX29PIKWtusWvW5 9KmCli+IAwkTCYTPEKnc4nZ6c7OGALbmySU6foaqPIPODF/plLjsk+3Weuy4oqVmuTbF BaHXJYoLd3IefuipxK+a3euhtaCXjIeG0ggEMWgWks+Z9EEK/+A+8NqePcSBJp6pEOue SvgQpHJZ0a3wt+2qeWo1DdEqVs+fCKTtpOkYmRzZbJcu4ZexM0JP53hh4xrNJs9PhRJn yOpQ== X-Gm-Message-State: AC+VfDxoZi6WVla5B05/fsKhri8K261E/lZxl1dIynkcDImh80PgDff2 dSxdrMBb0LFehjfNhwXyUAilXA== X-Received: by 2002:a2e:8895:0:b0:2af:2494:49ae with SMTP id k21-20020a2e8895000000b002af249449aemr710197lji.44.1685449861206; Tue, 30 May 2023 05:31:01 -0700 (PDT) Received: from [192.168.1.101] (abyj77.neoplus.adsl.tpnet.pl. [83.9.29.77]) by smtp.gmail.com with ESMTPSA id u18-20020a2e91d2000000b002a8b8baf542sm2854814ljg.126.2023.05.30.05.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 05:31:00 -0700 (PDT) From: Konrad Dybcio Date: Tue, 30 May 2023 14:30:49 +0200 Subject: [PATCH v4 15/17] media: venus: Introduce accessors for remapped hfi_buffer_reqs members MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230228-topic-venus-v4-15-feebb2f6e9b8@linaro.org> References: <20230228-topic-venus-v4-0-feebb2f6e9b8@linaro.org> In-Reply-To: <20230228-topic-venus-v4-0-feebb2f6e9b8@linaro.org> To: Stanimir Varbanov , Vikash Garodia , Andy Gross , Bjorn Andersson , Mauro Carvalho Chehab , Dikshita Agarwal , Bryan O'Donoghue , Mansur Alisha Shaik , Jonathan Marek , Hans Verkuil , Dikshita Agarwal Cc: Mauro Carvalho Chehab , Stanimir Varbanov , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Marijn Suijten , Konrad Dybcio , Vikash Garodia X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1685449837; l=7633; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=aA0naIs45zu3yNzQJ0HG4OVDJcjMhRj/HvlsjYQeb50=; b=/inUE1GgKPnZpyWe2gXCYBfHan/3lP2J8Zy/ajrDuYfv3sVd4GrBebFlxjZ3xefS1fkOVN6mL NNrlgzleL7vAGk/HNAD0BOzfGmE8A1x12waiLuYruLiAv4eOofkdITA X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we have macros to access these, but they don't provide a way to override the remapped fields. Replace the macros with actual get/set pairs to fix that. Reviewed-by: Bryan O'Donoghue Signed-off-by: Konrad Dybcio --- drivers/media/platform/qcom/venus/helpers.c | 2 +- drivers/media/platform/qcom/venus/hfi_helper.h | 61 ++++++++++++++++++++++---- drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 8 ++-- drivers/media/platform/qcom/venus/vdec_ctrls.c | 2 +- drivers/media/platform/qcom/venus/venc.c | 4 +- drivers/media/platform/qcom/venus/venc_ctrls.c | 2 +- 7 files changed, 63 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 1822e85ab6bf..b70bd3dac4df 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -189,7 +189,7 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst) if (ret) return ret; - count = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + count = hfi_bufreq_get_count_min(&bufreq, ver); for (i = 0; i < count; i++) { buf = kzalloc(sizeof(*buf), GFP_KERNEL); diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 0abbc50c5864..e4c05d62cfc7 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -1170,14 +1170,6 @@ struct hfi_buffer_display_hold_count_actual { u32 hold_count; }; -/* HFI 4XX reorder the fields, use these macros */ -#define HFI_BUFREQ_HOLD_COUNT(bufreq, ver) \ - ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count) -#define HFI_BUFREQ_COUNT_MIN(bufreq, ver) \ - ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min) -#define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \ - ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0) - struct hfi_buffer_requirements { u32 type; u32 size; @@ -1189,6 +1181,59 @@ struct hfi_buffer_requirements { u32 alignment; }; +/* On HFI 4XX, some of the struct members have been swapped. */ +static inline u32 hfi_bufreq_get_hold_count(struct hfi_buffer_requirements *req, + u32 ver) +{ + if (ver == HFI_VERSION_4XX) + return 0; + + return req->hold_count; +}; + +static inline u32 hfi_bufreq_get_count_min(struct hfi_buffer_requirements *req, + u32 ver) +{ + if (ver == HFI_VERSION_4XX) + return req->hold_count; + + return req->count_min; +}; + +static inline u32 hfi_bufreq_get_count_min_host(struct hfi_buffer_requirements *req, + u32 ver) +{ + if (ver == HFI_VERSION_4XX) + return req->count_min; + + return 0; +}; + +static inline void hfi_bufreq_set_hold_count(struct hfi_buffer_requirements *req, + u32 ver, u32 val) +{ + if (ver == HFI_VERSION_4XX) + return; + + req->hold_count = val; +}; + +static inline void hfi_bufreq_set_count_min(struct hfi_buffer_requirements *req, + u32 ver, u32 val) +{ + if (ver == HFI_VERSION_4XX) + req->hold_count = val; + + req->count_min = val; +}; + +static inline void hfi_bufreq_set_count_min_host(struct hfi_buffer_requirements *req, + u32 ver, u32 val) +{ + if (ver == HFI_VERSION_4XX) + req->count_min = val; +}; + struct hfi_data_payload { u32 size; u8 data[1]; diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index 3d5dadfa1900..7cab685a2ec8 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -99,7 +99,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS: data_ptr += sizeof(u32); bufreq = (struct hfi_buffer_requirements *)data_ptr; - event.buf_count = HFI_BUFREQ_COUNT_MIN(bufreq, ver); + event.buf_count = hfi_bufreq_get_count_min(bufreq, ver); data_ptr += sizeof(*bufreq); break; case HFI_INDEX_EXTRADATA_INPUT_CROP: diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 063a8b0d357b..2a1e038f92cf 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -899,13 +899,13 @@ static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num, if (ret) return ret; - *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + *in_num = hfi_bufreq_get_count_min(&bufreq, ver); ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); if (ret) return ret; - *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + *out_num = hfi_bufreq_get_count_min(&bufreq, ver); return 0; } @@ -1019,14 +1019,14 @@ static int vdec_verify_conf(struct venus_inst *inst) return ret; if (inst->num_output_bufs < bufreq.count_actual || - inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) + inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) return -EINVAL; ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); if (ret) return ret; - if (inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) + if (inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/venus/vdec_ctrls.c b/drivers/media/platform/qcom/venus/vdec_ctrls.c index fbe12a608b21..7e0f29bf7fae 100644 --- a/drivers/media/platform/qcom/venus/vdec_ctrls.c +++ b/drivers/media/platform/qcom/venus/vdec_ctrls.c @@ -79,7 +79,7 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); if (!ret) - ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver); break; default: return -EINVAL; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index b60772cc2cdc..d2e2d3108752 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1207,7 +1207,7 @@ static int venc_verify_conf(struct venus_inst *inst) return ret; if (inst->num_output_bufs < bufreq.count_actual || - inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) + inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) return -EINVAL; ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); @@ -1215,7 +1215,7 @@ static int venc_verify_conf(struct venus_inst *inst) return ret; if (inst->num_input_bufs < bufreq.count_actual || - inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) + inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index 7468e43800a9..d9d2a293f3ef 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -358,7 +358,7 @@ static int venc_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); if (!ret) - ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver); break; default: return -EINVAL; -- 2.40.1