Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2099837imu; Thu, 17 Jan 2019 08:22:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4h5GTxqPYpTKGtSgh91T4RZJWc4lJvZNkeMujTZYo/+p/0ltkJGjX6vlKDl3ecBrZjt8zA X-Received: by 2002:a65:4381:: with SMTP id m1mr13745837pgp.358.1547742169424; Thu, 17 Jan 2019 08:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547742169; cv=none; d=google.com; s=arc-20160816; b=jWCo6rFdR3DGD+KPIB75Sl+rjYFUnwTyrERLliN1jo0IFhsW0FAyBT6CeYAqfkJNoD 4ONAVzIHF3xbWSOvGPLrwRgfe8uRP44FFMS6BhN8k0Y5vagX0lWqy0TtDyeJUVgmh+XZ vnBHrGGjO6iPZLpFTnxoaSs9kD1y4ro3RJw5eBwdRMNrfSK7WWzBdxOzEPRLvechOuKE dOLv0EFJhOd1RZZZKYp1vF01t+gJH7rCwSZfanhAy0zXSDqCw7Yykb5kWDGtfstliZPM r5hoT62nZjDMRU+XKx64/AOA4tkgW/sibZKa0cqQ0zlFrUAx24y6xn5CqGC9zx7ZSZEj Qx5Q== 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=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=r44bHfssXhWL1jzvcPUDwXRhkXLTeVzA4Meiwg0/820prhaL9nM74ar8lfK3etbrmD fDxWiMuwlzS64ZJuD+GdD/WBsd+AwXfXomwCmJUKiTyGKV/FYg11BCrUozak7T0wjch4 3GYNYraOkqbIpHln+5N12GsCJDIHInItRJuD2gbRQc4cGcIKBk7x2yhGwdvm+2op+Ivx xjTjS6NcYJRM9kY9zPS4BCFodAiflqiy/rYjMLvb4TVjS9Hm4AO3EpHogpsdhg9Qr4MD mXZnIOHWVSxgCM7AaJavXQKn2mQAgNdoijaDi7+ULuZ/wsPoOD9FkRGpXPSvryq2VNoM DQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fpaoJNuE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si326638pfd.236.2019.01.17.08.22.33; Thu, 17 Jan 2019 08:22:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fpaoJNuE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728882AbfAQQVP (ORCPT + 99 others); Thu, 17 Jan 2019 11:21:15 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52217 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728998AbfAQQVM (ORCPT ); Thu, 17 Jan 2019 11:21:12 -0500 Received: by mail-wm1-f68.google.com with SMTP id b11so1699609wmj.1 for ; Thu, 17 Jan 2019 08:21:10 -0800 (PST) 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=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=fpaoJNuEYdX6Q0gc/SsxQ6igfVQvhHken4mff/K5Ft8HGQFDwRbdfnWWzHgsruKouG ElA8aeaDwJxzOvfvsBw7co33LD4k2mu/57A348xKulDYFWcUCYFJFdqtfNFV4FDh4kbp Jh+QuhbhdI3mohfZsg01luVG6YLvIpqntHI4Y= 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=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=t2v/VQuRsySnH8LEqzW0UtYh7QOG3SVe84Tfq7tOBcjzp8uTdjGECehiuvolqb0G2O w9vctuY9qqhkDxb6jf/mXQsR2qOhzxo5teD+n+6irzWqfBW9uRNBsCEeXsln9N6hKwIv W6mdG3lnwIqAJHg3bNsKPqb26ErtRQYTNRm0NqqkOkb+JBho9BKByi1LuGSZ6ssHpvvH sjs4fdvOkunG/wDgMhx28yQjORdr5IxISY7vh8le5qzl3C7sSpZGIaU+outkgb73HTRn Z0FJEu21bmL26GWHAqP3XgEFqbzHP7iH8Z/HyfwTPVrcO/0bl0jOK1a7GnsvzLGHfBOO eCAg== X-Gm-Message-State: AJcUukfi4+xOmiWd3Ht28AVeL8JxdJC5kBkhTPnb43IjZKMkeALBRsYn gDBR16gEQA+OA9DBKmN2Jn940u9rxiM= X-Received: by 2002:a1c:de57:: with SMTP id v84mr12264913wmg.55.1547742069669; Thu, 17 Jan 2019 08:21:09 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id v133sm31124734wmf.19.2019.01.17.08.21.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 08:21:09 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Malathi Gottam , Stanimir Varbanov Subject: [PATCH 07/10] venus: helpers: add three more helper functions Date: Thu, 17 Jan 2019 18:20:05 +0200 Message-Id: <20190117162008.25217-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117162008.25217-1-stanimir.varbanov@linaro.org> References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds three more helper functions: * for internal buffers reallocation, applicable when we are doing dynamic resolution change * for initial buffer processing of capture and output queue buffer types All of them will be needed for stateful Codec API support. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 82 +++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 + 2 files changed, 84 insertions(+) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index f33bbfea3576..637ce7b82d94 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -322,6 +322,52 @@ int venus_helper_intbufs_free(struct venus_inst *inst) } EXPORT_SYMBOL_GPL(venus_helper_intbufs_free); +int venus_helper_intbufs_realloc(struct venus_inst *inst) +{ + enum hfi_version ver = inst->core->res->hfi_version; + struct hfi_buffer_desc bd; + struct intbuf *buf, *n; + int ret; + + list_for_each_entry_safe(buf, n, &inst->internalbufs, list) { + if (buf->type == HFI_BUFFER_INTERNAL_PERSIST || + buf->type == HFI_BUFFER_INTERNAL_PERSIST_1) + continue; + + memset(&bd, 0, sizeof(bd)); + bd.buffer_size = buf->size; + bd.buffer_type = buf->type; + bd.num_buffers = 1; + bd.device_addr = buf->da; + bd.response_required = true; + + ret = hfi_session_unset_buffers(inst, &bd); + + dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da, + buf->attrs); + + list_del_init(&buf->list); + kfree(buf); + } + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH(ver)); + if (ret) + goto err; + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_1(ver)); + if (ret) + goto err; + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_2(ver)); + if (ret) + goto err; + + return 0; +err: + return ret; +} +EXPORT_SYMBOL_GPL(venus_helper_intbufs_realloc); + static u32 load_per_instance(struct venus_inst *inst) { u32 mbs; @@ -1050,6 +1096,42 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming); +int venus_helper_process_initial_cap_bufs(struct venus_inst *inst) +{ + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct v4l2_m2m_buffer *buf, *n; + int ret; + + v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, buf, n) { + ret = session_process_buf(inst, &buf->vb); + if (ret) { + return_buf_error(inst, &buf->vb); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_process_initial_cap_bufs); + +int venus_helper_process_initial_out_bufs(struct venus_inst *inst) +{ + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct v4l2_m2m_buffer *buf, *n; + int ret; + + v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buf, n) { + ret = session_process_buf(inst, &buf->vb); + if (ret) { + return_buf_error(inst, &buf->vb); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_process_initial_out_bufs); + int venus_helper_vb2_start_streaming(struct venus_inst *inst) { struct venus_core *core = inst->core; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 24faae5abd93..2ec1c1a8b416 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -69,4 +69,6 @@ int venus_helper_intbufs_realloc(struct venus_inst *inst); int venus_helper_queue_dpb_bufs(struct venus_inst *inst); int venus_helper_unregister_bufs(struct venus_inst *inst); int venus_helper_load_scale_clocks(struct venus_core *core); +int venus_helper_process_initial_cap_bufs(struct venus_inst *inst); +int venus_helper_process_initial_out_bufs(struct venus_inst *inst); #endif -- 2.17.1