From patchwork Tue Oct 19 08:43:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dillon Min X-Patchwork-Id: 12569105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 882B7C4332F for ; Tue, 19 Oct 2021 08:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 674476139D for ; Tue, 19 Oct 2021 08:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234849AbhJSIqL (ORCPT ); Tue, 19 Oct 2021 04:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbhJSIqI (ORCPT ); Tue, 19 Oct 2021 04:46:08 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AC5C06161C; Tue, 19 Oct 2021 01:43:54 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id h193so3307008pgc.1; Tue, 19 Oct 2021 01:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9YChj8J53dFLEqWV9ieYXRrVD4Lc/MeGw3UeZhjNZXM=; b=g4s5EQwnsEOIrfK9LTCG1Do9I4ns5QjjtnT8BbyphPBkZR5PfD0DsPkxWAkhVBfgGc dBeVvyoohTzJGLio0rN6jzHwH54mE7T4q7hvRNaSigeQnMf/MGYFAekgRoV817VIsM4z cFPGaKT9PcXdahMs4b76gRbvaTsL94e+HIPPdlAhNUUmFByoqkwLiplqbQ86y9wAD8BV HWifptFCBJe9AehPjUd1zndYb2N3hrxb1joaoX6ggh2lrq0XU+83MjYjn1flyoIFOopZ dxf/lRerarzVkZPUCzwVkDcZEaclMHG/wlUkp7Mdsj1DMQqz0bF9NgM8NxOppeIn6txp PBeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9YChj8J53dFLEqWV9ieYXRrVD4Lc/MeGw3UeZhjNZXM=; b=5LMRmeQBhHSwu/O8MYqmJh9/4vQhY3byyp3BsdOhdvCSm5AsdDq2AQcA42IfysWa/C DvnITDSGG7FcGxu3MVtyKI0SSK9chkKNIoq4PSJqRIeRGN9UIJtgpAWLHHTwsziVZNiy eQ+j1myFAq87jfjFms05A9F4ZvBb0Own0HENMjYrpzU3oJ5dWshzMhdzzyuOzHqArnNq l/mj4tk0DwQctGfiCk5RWmagqXUgfvB2j8Cr07aVzb1R4hCKBu4zYZtqZ+YGo+OCMw5n Fo1XiFjVigKaqAUGi5cOFbciciy73nCZf0uCFqs9dnB3qHjD2aWobyfx6iQKcKTMZyxW RxRw== X-Gm-Message-State: AOAM530oA4nTlOhhlr0qlqFHA3uCO1VBvI4MxbXSXfnEHKUJ98l229je x3LinJ7b4xS3ovqyBw19mxM= X-Google-Smtp-Source: ABdhPJwwWc57B7dBY3YvhwQ4eK4FwfG9BLFjg0qB4PwIkbSpAd0uRo0YikHIm4xnTbA/VGX8r6Ciew== X-Received: by 2002:a62:5304:0:b0:44c:719c:a2c with SMTP id h4-20020a625304000000b0044c719c0a2cmr33506905pfb.13.1634633034123; Tue, 19 Oct 2021 01:43:54 -0700 (PDT) Received: from fmin-OptiPlex-7060.nreal.work ([137.59.103.165]) by smtp.gmail.com with ESMTPSA id c11sm1824716pji.38.2021.10.19.01.43.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Oct 2021 01:43:53 -0700 (PDT) From: Dillon Min To: mchehab@kernel.org, mchehab+huawei@kernel.org, hverkuil-cisco@xs4all.nl, ezequiel@collabora.com, gnurou@gmail.com, pihsun@chromium.org, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, gabriel.fernandez@st.com, gabriel.fernandez@foss.st.com Cc: patrice.chotard@foss.st.com, hugues.fruchet@foss.st.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v6 05/10] media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu platform Date: Tue, 19 Oct 2021 16:43:18 +0800 Message-Id: <1634633003-18132-6-git-send-email-dillon.minfei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634633003-18132-1-git-send-email-dillon.minfei@gmail.com> References: <1634633003-18132-1-git-send-email-dillon.minfei@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For platforms without MMU the m2m provides a helper method v4l2_m2m_get_unmapped_area(), The mmap() routines will call this to get a proposed address for the mapping. More detailed information about get_unmapped_area can be found in Documentation/nommu-mmap.txt Signed-off-by: Dillon Min --- v6: no change. drivers/media/v4l2-core/v4l2-mem2mem.c | 21 +++++++++++++++++++++ include/media/v4l2-mem2mem.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index e7f4bf5bc8dd..e2654b422334 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -966,6 +966,27 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, } EXPORT_SYMBOL(v4l2_m2m_mmap); +#ifndef CONFIG_MMU +unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + struct v4l2_fh *fh = file->private_data; + unsigned long offset = pgoff << PAGE_SHIFT; + struct vb2_queue *vq; + + if (offset < DST_QUEUE_OFF_BASE) { + vq = v4l2_m2m_get_src_vq(fh->m2m_ctx); + } else { + vq = v4l2_m2m_get_dst_vq(fh->m2m_ctx); + pgoff -= (DST_QUEUE_OFF_BASE >> PAGE_SHIFT); + } + + return vb2_get_unmapped_area(vq, addr, len, pgoff, flags); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_get_unmapped_area); +#endif + #if defined(CONFIG_MEDIA_CONTROLLER) void v4l2_m2m_unregister_media_controller(struct v4l2_m2m_dev *m2m_dev) { diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 5a91b548ecc0..fdbd5257e020 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -495,6 +495,11 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct vm_area_struct *vma); +#ifndef CONFIG_MMU +unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); +#endif /** * v4l2_m2m_init() - initialize per-driver m2m data *