diff mbox series

[6/7] media: v4l2-mem2mem: add v4l2_m2m_get_unmapped_area for no-mmu platform

Message ID 1621508727-24486-7-git-send-email-dillon.minfei@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/7] media: admin-guide: add stm32-dma2d description | expand

Commit Message

Dillon Min May 20, 2021, 11:05 a.m. UTC
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(+)

Comments

Hans Verkuil June 17, 2021, 9:58 a.m. UTC | #1
On 20/05/2021 13:05, dillon.minfei@gmail.com wrote:
> 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

I'm getting checkpatch.pl --strict warnings:

CHECK: Alignment should match open parenthesis
#31: FILE: drivers/media/v4l2-core/v4l2-mem2mem.c:971:
+unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
+               unsigned long len, unsigned long pgoff, unsigned long flags)

CHECK: Alignment should match open parenthesis
#62: FILE: include/media/v4l2-mem2mem.h:500:
+unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
+               unsigned long len, unsigned long pgoff, unsigned long flags);

Regards,

	Hans

> 
> 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
>   *
>
Dillon Min June 17, 2021, 10:40 a.m. UTC | #2
Hi Hans,

On Thu, Jun 17, 2021 at 5:58 PM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
>
> On 20/05/2021 13:05, dillon.minfei@gmail.com wrote:
> > 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
>
> I'm getting checkpatch.pl --strict warnings:
>
> CHECK: Alignment should match open parenthesis
> #31: FILE: drivers/media/v4l2-core/v4l2-mem2mem.c:971:
> +unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
> +               unsigned long len, unsigned long pgoff, unsigned long flags)
>
> CHECK: Alignment should match open parenthesis
> #62: FILE: include/media/v4l2-mem2mem.h:500:
> +unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
> +               unsigned long len, unsigned long pgoff, unsigned long flags);

Okay, I will add the "--strict" check to my regular patch submission.
Thanks for the reminder.

Best Regards
Dillon

>
> Regards,
>
>         Hans
>
> >
> > 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
> >   *
> >
>
diff mbox series

Patch

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
  *