linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dillon.minfei@gmail.com
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
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, Dillon Min <dillon.minfei@gmail.com>
Subject: [PATCH 6/7] media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu platform
Date: Thu, 20 May 2021 19:05:26 +0800	[thread overview]
Message-ID: <1621508727-24486-7-git-send-email-dillon.minfei@gmail.com> (raw)
In-Reply-To: <1621508727-24486-1-git-send-email-dillon.minfei@gmail.com>

From: Dillon Min <dillon.minfei@gmail.com>

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 <dillon.minfei@gmail.com>
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 20 ++++++++++++++++++++
 include/media/v4l2-mem2mem.h           |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index e7f4bf5bc8dd..f82a18ecab2f 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -966,6 +966,26 @@ 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..91269227c265 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -495,6 +495,10 @@ __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
  *
-- 
2.7.4


  parent reply	other threads:[~2021-05-20 12:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 11:05 [PATCH 0/7] Add support for DMA2D of STMicroelectronics STM32 SoC series dillon.minfei
2021-05-20 11:05 ` [PATCH 1/7] media: admin-guide: add stm32-dma2d description dillon.minfei
2021-06-17  9:56   ` Hans Verkuil
2021-06-17 10:14     ` Dillon Min
2021-05-20 11:05 ` [PATCH 2/7] media: dt-bindings: media: add document for STM32 DMA2D bindings dillon.minfei
2021-05-21  2:03   ` Rob Herring
2021-05-20 11:05 ` [PATCH 3/7] clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after kernel startup dillon.minfei
2021-06-17  9:57   ` Hans Verkuil
2021-06-17 10:21     ` Dillon Min
2021-05-20 11:05 ` [PATCH 4/7] ARM: dts: stm32: Enable DMA2D support on STM32F429 MCU dillon.minfei
2021-05-20 11:05 ` [PATCH 5/7] ARM: dts: stm32: Enable DMA2D on STM32F469-DISCO board dillon.minfei
2021-05-20 11:05 ` dillon.minfei [this message]
2021-06-17  9:58   ` [PATCH 6/7] media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu platform Hans Verkuil
2021-06-17 10:40     ` Dillon Min
2021-05-20 11:05 ` [PATCH 7/7] media: stm32-dma2d: STM32 DMA2D driver dillon.minfei
2021-06-17 10:18   ` Hans Verkuil
2021-06-17 10:56     ` Dillon Min
2021-06-17 11:23       ` Hans Verkuil
2021-06-09 13:46 ` [PATCH 0/7] Add support for DMA2D of STMicroelectronics STM32 SoC series Dillon Min
2021-06-17  9:54 ` Hans Verkuil
2021-06-17 11:01   ` Dillon Min

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1621508727-24486-7-git-send-email-dillon.minfei@gmail.com \
    --to=dillon.minfei@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@collabora.com \
    --cc=gnurou@gmail.com \
    --cc=hugues.fruchet@foss.st.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=pihsun@chromium.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).