OSDN Git Service

tomoyo/tomoyo-test1.git
5 years agomedia: vimc: Remove or modify stream checks
André Almeida [Thu, 30 May 2019 13:19:56 +0000 (09:19 -0400)]
media: vimc: Remove or modify stream checks

Change the way subdevices check if the stream is running. Verify the stream
pointer instead of src_frame. This makes easier to get rid of the void* and
u8* that points to frames in the subdevices structs.

Remove checks that s_stream does on subdevices. They are redundant since
the Media Controller Framework doesn't allow two streaming on the same
media pipeline at the same time.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: media/doc: Allow sizeimage to be set by v4l clients
Stanimir Varbanov [Thu, 30 May 2019 09:33:12 +0000 (05:33 -0400)]
media: media/doc: Allow sizeimage to be set by v4l clients

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage
field description to allow v4l clients to set bigger image size
in case of variable length compressed data.

Presently s5p-mfc and mtk-vcodec codec drivers use that. Lets
make it obvious in the documentation.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: docs: fix minor typos
Marc Gonzalez [Wed, 5 Jun 2019 11:59:10 +0000 (07:59 -0400)]
media: docs: fix minor typos

Fix minor typos in the DVB demux documentation.

Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dvb: tag deprecated DVB APIs as such
Mauro Carvalho Chehab [Tue, 4 Jun 2019 14:41:20 +0000 (10:41 -0400)]
media: dvb: tag deprecated DVB APIs as such

There are three headers at DVB that should not be used on
future projects: audio.h, osd.h and video.h.

While this is already clear at the docs, make clear also at
the headers that those files should not be used on future
drivers.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: do not use C++ style comments in uapi headers
Masahiro Yamada [Tue, 4 Jun 2019 11:13:34 +0000 (07:13 -0400)]
media: do not use C++ style comments in uapi headers

Linux kernel tolerates C++ style comments these days. Actually, the
SPDX License tags for .c files start with //.

On the other hand, uapi headers are written in more strict C, where
the C++ comment style is forbidden.

[mchehab+samsung@kernel.org: fix a checkpatch --strict warning]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs
Hans Verkuil [Tue, 28 May 2019 08:34:37 +0000 (04:34 -0400)]
media: vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs

Use the new helper functions for the try_de/decoder_cmd ioctls.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
Hans Verkuil [Wed, 29 May 2019 06:45:59 +0000 (02:45 -0400)]
media: v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers

Most if not all codecs will need to implement these ioctls and
it is expected to be the same for all codecs. So add this to
the core v4l2-mem2mem framework so that this code can easily be
reused.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/media: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 09:39:41 +0000 (05:39 -0400)]
media: staging/media: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
all staging/media drivers in this patch.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: vc04_services/bcm2835-camera: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 11:19:57 +0000 (07:19 -0400)]
media: vc04_services/bcm2835-camera: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
this driver accordingly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: usb/gadget/f_uvc: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 11:19:55 +0000 (07:19 -0400)]
media: usb/gadget/f_uvc: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
this UVC gadget driver.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rtl2832_sdr: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 11:19:54 +0000 (07:19 -0400)]
media: rtl2832_sdr: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
this SDR driver in this patch.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: media/usb: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 11:19:53 +0000 (07:19 -0400)]
media: media/usb: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
all usb drivers in this patch.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: media/radio: set device_caps in struct video_device
Hans Verkuil [Tue, 4 Jun 2019 11:19:52 +0000 (07:19 -0400)]
media: media/radio: set device_caps in struct video_device

Instead of filling in the struct v4l2_capability device_caps
field, fill in the struct video_device device_caps field.

That way the V4L2 core knows what the capabilities of the
video device are.

But this only really works if all drivers use this, so convert
all radio drivers in this patch.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap, out}_mplane
Boris Brezillon [Tue, 4 Jun 2019 07:06:25 +0000 (03:06 -0400)]
media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap, out}_mplane

Support for multiplanar and singleplanar formats is mutually exclusive,
at least in practice. In our attempt to unify support for support for
mplane and !mplane in v4l, let's get rid of the
->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call
->vidioc_enum_fmt_{vid,out}_cap() instead.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
[hverkuil-cisco@xs4all.nl: fix typos: pirv -> priv and prov -> priv]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2: Make sure all drivers set _MPLANE caps in vdev->device_caps
Boris Brezillon [Tue, 4 Jun 2019 07:06:24 +0000 (03:06 -0400)]
media: v4l2: Make sure all drivers set _MPLANE caps in vdev->device_caps

This is needed if we want the core to be able to check _MPLANE support
without having to call the ->vidioc_querycap() hook.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: Fix vendor-prefixes YAML
Maxime Ripard [Mon, 3 Jun 2019 11:32:50 +0000 (07:32 -0400)]
media: dt-bindings: Fix vendor-prefixes YAML

Commit 8df39e16877f ("media: dt-bindings: media: Add vendor prefix for
allegro") introduced a new devicetree binding vendors, however with an
improper syntax making the resulting YAML impossible to parse. Let's fix
this.

Fixes: 8df39e16877f ("media: dt-bindings: media: Add vendor prefix for allegro")

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: fix two NULL vs IS_ERR() bugs
Dan Carpenter [Fri, 31 May 2019 14:20:49 +0000 (10:20 -0400)]
media: staging/imx: fix two NULL vs IS_ERR() bugs

The imx_media_pipeline_pad() function return NULL pointers on error, it
never returns error pointers.

Fixes: 3ef46bc97ca2 ("media: staging/imx: Improve pipeline searching")

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: platform: ao-cec-g12a: disable regmap fast_io for cec bus regmap
Neil Armstrong [Fri, 31 May 2019 10:33:15 +0000 (06:33 -0400)]
media: platform: ao-cec-g12a: disable regmap fast_io for cec bus regmap

With fast_io enabled, spinlock_irq is used for read/write operations,
thus leading to :
BUG: sleeping function called from invalid context at [snip]/ao-cec-g12a.c:379
 in_atomic(): 1, irqs_disabled(): 128, pid: 1451, name: irq/14-ff800280
[snip]
Call trace:
 dump_backtrace+0x0/0x180
 show_stack+0x14/0x1c
 dump_stack+0xa8/0xe0
 ___might_sleep+0xf4/0x104
 __might_sleep+0x4c/0x80
 meson_ao_cec_g12a_read+0x7c/0x164
 regmap_read+0x16c/0x1b0
 meson_ao_cec_g12a_irq_thread+0xcc/0x200
 irq_thread_fn+0x2c/0x60
 irq_thread+0x14c/0x1fc
 kthread+0x11c/0x12c
 ret_from_fork+0x10/0x18

Simply remove fast_io to use mutexes instead.

Fixes: b7778c46683c ("media: platform: meson: Add Amlogic Meson G12A AO CEC Controller driver")

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx23885: remove redundant assignment to err
Colin Ian King [Thu, 30 May 2019 18:59:24 +0000 (14:59 -0400)]
media: cx23885: remove redundant assignment to err

The variable err is assigned with a value that is never read and
it is re-assigned a new value later on.  The assignment is redundant
and can be removed.

Addresses-Coverity: ("Unused value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dvb-usb/cxusb-analog.c: fix coccinelle warning, use ktime.h
Hans Verkuil [Thu, 30 May 2019 06:45:48 +0000 (02:45 -0400)]
media: dvb-usb/cxusb-analog.c: fix coccinelle warning, use ktime.h

This patch fixes a coccinelle warning and includes ktime.h instead of
timekeeping.h. The first includes the latter, but the latter doesn't
exist before 3.17, causing problems for our compat build. It's easier
to just use ktime.h instead.

coccinelle warnings: (new ones prefixed by >>)

>> drivers/media/usb/dvb-usb/cxusb-analog.c:1498:41-42: WARNING: Use ARRAY_SIZE

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: wl128x: Fix some error handling in fm_v4l2_init_video_device()
Kefeng Wang [Thu, 30 May 2019 07:25:49 +0000 (03:25 -0400)]
media: wl128x: Fix some error handling in fm_v4l2_init_video_device()

X-Originating-IP: [10.175.113.25]
X-CFilter-Loop: Reflected
The fm_v4l2_init_video_device() forget to unregister v4l2/video device
in the error path, it could lead to UAF issue, eg,

  BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:836 [inline]
  BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:28 [inline]
  BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x92/0x690 kernel/locking/mutex.c:1206
  Read of size 8 at addr ffff8881e84a7c70 by task v4l_id/3659

  CPU: 1 PID: 3659 Comm: v4l_id Not tainted 5.1.0 #8
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
  Call Trace:
   __dump_stack lib/dump_stack.c:77 [inline]
   dump_stack+0xa9/0x10e lib/dump_stack.c:113
   print_address_description+0x65/0x270 mm/kasan/report.c:187
   kasan_report+0x149/0x18d mm/kasan/report.c:317
   atomic64_read include/asm-generic/atomic-instrumented.h:836 [inline]
   atomic_long_read include/asm-generic/atomic-long.h:28 [inline]
   __mutex_unlock_slowpath+0x92/0x690 kernel/locking/mutex.c:1206
   fm_v4l2_fops_open+0xac/0x120 [fm_drv]
   v4l2_open+0x191/0x390 [videodev]
   chrdev_open+0x20d/0x570 fs/char_dev.c:417
   do_dentry_open+0x700/0xf30 fs/open.c:777
   do_last fs/namei.c:3416 [inline]
   path_openat+0x7c4/0x2a90 fs/namei.c:3532
   do_filp_open+0x1a5/0x2b0 fs/namei.c:3563
   do_sys_open+0x302/0x490 fs/open.c:1069
   do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290
   entry_SYSCALL_64_after_hwframe+0x49/0xbe
  RIP: 0033:0x7f8180c17c8e
  ...
  Allocated by task 3642:
   set_track mm/kasan/common.c:87 [inline]
   __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:497
   fm_drv_init+0x13/0x1000 [fm_drv]
   do_one_initcall+0xbc/0x47d init/main.c:901
   do_init_module+0x1b5/0x547 kernel/module.c:3456
   load_module+0x6405/0x8c10 kernel/module.c:3804
   __do_sys_finit_module+0x162/0x190 kernel/module.c:3898
   do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290
   entry_SYSCALL_64_after_hwframe+0x49/0xbe

  Freed by task 3642:
   set_track mm/kasan/common.c:87 [inline]
   __kasan_slab_free+0x130/0x180 mm/kasan/common.c:459
   slab_free_hook mm/slub.c:1429 [inline]
   slab_free_freelist_hook mm/slub.c:1456 [inline]
   slab_free mm/slub.c:3003 [inline]
   kfree+0xe1/0x270 mm/slub.c:3958
   fm_drv_init+0x1e6/0x1000 [fm_drv]
   do_one_initcall+0xbc/0x47d init/main.c:901
   do_init_module+0x1b5/0x547 kernel/module.c:3456
   load_module+0x6405/0x8c10 kernel/module.c:3804
   __do_sys_finit_module+0x162/0x190 kernel/module.c:3898
   do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290
   entry_SYSCALL_64_after_hwframe+0x49/0xbe

Add relevant unregister functions to fix it.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: Staging: media: Release the correct resource in an error handling path
Christophe JAILLET [Sun, 20 Aug 2017 16:49:01 +0000 (12:49 -0400)]
media: Staging: media: Release the correct resource in an error handling path

'res' is reassigned several times in the function and if we 'goto
error_unmap', its value is not the returned value of 'request_mem_region()'
anymore.

Introduce a new 'struct resource *' variable (i.e. res2) to keep a pointer
to the right resource, if needed in the error handling path.

Fixes: 4b4eda001704 ("Staging: media: Unmap and release region obtained by ioremap_nocache")

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: omap3isp: constify platform_device_id
Arvind Yadav [Tue, 15 Aug 2017 11:23:42 +0000 (07:23 -0400)]
media: omap3isp: constify platform_device_id

platform_device_id are not supposed to change at runtime. All functions
working with platform_device_id provided by <linux/platform_device.h>
work with const platform_device_id. So mark the non-const structs as
const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: media: davinci_vpfe: use __func__ for function names
Diwakar Sharma [Thu, 27 Jul 2017 17:01:23 +0000 (13:01 -0400)]
media: staging: media: davinci_vpfe: use __func__ for function names

Checkpatch reported warnings for use of embedded function names.
Use __func__ instead of embedded function names.

[mchehab+samsung@kernel.org: rebased on the top of upstream]
Signed-off-by: Diwakar Sharma <sharmalxmail@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: omap3isp: Call video_unregister_device() unconditionally
Sakari Ailus [Mon, 20 Feb 2017 15:22:18 +0000 (10:22 -0500)]
media: omap3isp: Call video_unregister_device() unconditionally

video_unregister_device() can be called on a never or an already
unregistered device. Drop the redundant check.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: omap3isp: Don't rely on devm for memory resource management
Sakari Ailus [Thu, 13 Jul 2017 15:23:44 +0000 (11:23 -0400)]
media: omap3isp: Don't rely on devm for memory resource management

devm functions are fine for managing resources that are directly related
to the device at hand and that have no other dependencies. However, a
process holding a file handle to a device created by a driver for a device
may result in the file handle left behind after the device is long gone.
This will result in accessing released (and potentially reallocated)
memory.

Instead, manage the memory resources in the driver. Releasing the
resources can be later on bound to e.g. by releasing a reference.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: media: davinci_vpfe: Replace a bit shift
Arushi Singhal [Wed, 29 Mar 2017 15:13:20 +0000 (11:13 -0400)]
media: staging: media: davinci_vpfe: Replace a bit shift

This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

[mchehab+samsung@kernel.org: rebase on the top of upstream]
Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization...
Shailendra Verma [Fri, 25 Nov 2016 04:57:34 +0000 (23:57 -0500)]
media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails.

Fix to avoid possible memory leak if the decoder initialization
got failed.Free the allocated memory for file handle object
before return in case decoder initialization fails.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: videobuf-dma-contig: Use size of buffer in mmap not vma size
Andrew F. Davis [Fri, 29 Mar 2019 17:34:27 +0000 (13:34 -0400)]
media: videobuf-dma-contig: Use size of buffer in mmap not vma size

The size of the vma can be larger than the size of the backing buffer.
Use the buffer size over vma size to prevent exposing extra memory
to userspace.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx231xx-dvb: fix memory leak in dvb_fini()
Young Xiao [Tue, 28 May 2019 12:38:13 +0000 (08:38 -0400)]
media: cx231xx-dvb: fix memory leak in dvb_fini()

In dvb_init(), dev->dvb is allocated by kzalloc.
Therefore, it must be freed being set to NULL.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: em28xx: use usb_to_input_id() rather than handrolling it
Sean Young [Thu, 23 May 2019 10:01:51 +0000 (06:01 -0400)]
media: em28xx: use usb_to_input_id() rather than handrolling it

This also populates the version member correctly.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: em28xx: use common code for decoding nec scancodes
Sean Young [Thu, 23 May 2019 09:31:11 +0000 (05:31 -0400)]
media: em28xx: use common code for decoding nec scancodes

Tested on WinTV-HVR-930C.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: em28xx: give RC device proper name
Sean Young [Thu, 23 May 2019 08:48:11 +0000 (04:48 -0400)]
media: em28xx: give RC device proper name

Give the RC device the name of the board rather than "1-2:1.0 IR".

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: sun6i: Support A83T variant
Chen-Yu Tsai [Mon, 20 May 2019 15:06:36 +0000 (11:06 -0400)]
media: sun6i: Support A83T variant

The A83T SoC has a camera sensor interface (known as CSI in Allwinner
lingo), which is similar to the one found on the A64 and H3. The only
difference seems to be that support of MIPI CSI through a connected
MIPI CSI-2 bridge.

Add support for this variant.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: sun6i-csi: Add compatible string for A83T variant
Chen-Yu Tsai [Mon, 20 May 2019 15:06:35 +0000 (11:06 -0400)]
media: dt-bindings: media: sun6i-csi: Add compatible string for A83T variant

The A83T SoC has a camera sensor interface (known as CSI in Allwinner
lingo), which is similar to the one found on the A64 and H3. The only
difference seems to be that support of MIPI CSI through a connected
MIPI CSI-2 bridge.

Add a compatible string for this variant.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: ov8856: modify register to fix test pattern
Shawn Tu [Mon, 27 May 2019 02:26:05 +0000 (22:26 -0400)]
media: ov8856: modify register to fix test pattern

modify registers to fix bayer order in test pattern mode

Signed-off-by: Shawn Tu <shawnx.tu@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: imgu: Drop support for other page sizes
Sakari Ailus [Tue, 19 Feb 2019 14:17:02 +0000 (09:17 -0500)]
media: staging: imgu: Drop support for other page sizes

The hardware only supports 4ki pages; drop support for other sizes.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: imgu: Address compiler / checker warnings in MMU code
Sakari Ailus [Tue, 19 Feb 2019 14:32:06 +0000 (09:32 -0500)]
media: staging: imgu: Address compiler / checker warnings in MMU code

Address C compiler, sparse and smatch warnings and little style issues in
the IMGU MMU code.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: imgu: Remove redundant checks
Sakari Ailus [Mon, 18 Feb 2019 16:33:54 +0000 (11:33 -0500)]
media: staging: imgu: Remove redundant checks

Remove redundant checks for less than zero on unsigned variables.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: imgu: Address a compiler warning on alignment
Sakari Ailus [Mon, 18 Feb 2019 16:29:13 +0000 (11:29 -0500)]
media: staging: imgu: Address a compiler warning on alignment

Address a compiler warnings on alignment of struct ipu3_uapi_awb_fr_config_s
by adding __attribute__((aligned(32))) to a struct member of that type as
well.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Rajmohan Mani <rajmohan.mani@intel.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Add support for MPEG-2 decoding on RK3288
Jonas Karlman [Tue, 28 May 2019 17:02:31 +0000 (13:02 -0400)]
media: rockchip/vpu: Add support for MPEG-2 decoding on RK3288

Add necessary bits to support MPEG2 decoding on RK3288.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Add MPEG2 decoding support to RK3399
Jonas Karlman [Tue, 28 May 2019 17:02:30 +0000 (13:02 -0400)]
media: rockchip/vpu: Add MPEG2 decoding support to RK3399

Add the necessary bits to support MPEG2 decoding on RK3399.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Add infra to support MPEG-2 decoding
Jonas Karlman [Tue, 28 May 2019 17:02:29 +0000 (13:02 -0400)]
media: rockchip/vpu: Add infra to support MPEG-2 decoding

Only adds structs and helpers to allow supporting MPEG-2 decoding on
rockchip SoCs. Support for RK3399 and RK3288 will be added in separate
commits

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Add support for non-standard controls
Ezequiel Garcia [Tue, 28 May 2019 17:02:28 +0000 (13:02 -0400)]
media: rockchip/vpu: Add support for non-standard controls

Rework the way controls are registered by the driver,
so it can support non-standard controls, such as those
used by stateless codecs.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Add decoder boilerplate
Ezequiel Garcia [Tue, 28 May 2019 17:02:27 +0000 (13:02 -0400)]
media: rockchip/vpu: Add decoder boilerplate

This commit adds the needed boilerplate code to support the VPU
in decoding operation. Two v4l2 interfaces are exposed, one for
encoding and one for decoding, but a single m2m device is shared
by them, so jobs are properly serialized.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Prepare things to support decoders
Boris Brezillon [Tue, 28 May 2019 17:02:26 +0000 (13:02 -0400)]
media: rockchip/vpu: Prepare things to support decoders

The code in rockchip_vpu_v4l2 was hardcoded for encoder support.
Modify it more generic to support the decoder case so that we can
re-use the same vb2/v4l2 ops for both devices.

Co-developed-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Provide a helper to reset both src and dst formats
Boris Brezillon [Tue, 28 May 2019 17:02:25 +0000 (13:02 -0400)]
media: rockchip/vpu: Provide a helper to reset both src and dst formats

When initializing a context, the core wants to reset both src and dst
formats. Right now the order doesn't matter, but if we want to have a
valid default width/height on the non-coded/raw format side (src in
case of encoders, dst in case of decoders), we need to reset those
formats in the right order: first the coded-format side, then the other,
such that width and height on the raw format side can be taken from
the coded format.

Let's provide a helper that will reset both formats and make sure this
is done in the right order.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Move encoder logic to a common place
Boris Brezillon [Tue, 28 May 2019 17:02:24 +0000 (13:02 -0400)]
media: rockchip/vpu: Move encoder logic to a common place

The V4L2/VB2 implementation for the encoder and decoder logic are very
similar, so let's rename rockchip_vpu_enc.c file into
rockchip_vpu_v4l2.c and remove the _enc_ part in objects/functions
exposed in rockchip_vpu_v4l2.h. We also rename the enc_queue_init()
function (in rockchip_vpu_drv.c) queue_init() since it will be used
to initialize both type of queues.

The implementation itself will be patched to support the decoding case
when decoder support is added.

Suggested-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Rename rockchip_vpu_common.h into rockchip_vpu_v4l2.h
Boris Brezillon [Tue, 28 May 2019 17:02:23 +0000 (13:02 -0400)]
media: rockchip/vpu: Rename rockchip_vpu_common.h into rockchip_vpu_v4l2.h

We're about to add prototypes for the vb2/v4l2 helpers shared by the
encoder/decoder logic in this file, so let's pick a name that reflects
that (rockchip_vpu_common.h was a bit to generic).

Suggested-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Support the Request API
Ezequiel Garcia [Tue, 28 May 2019 17:02:22 +0000 (13:02 -0400)]
media: rockchip/vpu: Support the Request API

Introduce support for the Request API. Although the JPEG encoder
does not mandate using the Request API, it's perfectly possible to
use it, if the application wants to.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Open-code media controller register
Ezequiel Garcia [Tue, 28 May 2019 17:02:21 +0000 (13:02 -0400)]
media: rockchip/vpu: Open-code media controller register

In preparation to support decoders, using a single memory-to-memory
device, we need to roll our own media controller entities registration.

To do that, we define a rockchip_vpu_func object that embeds the
video_device object plus all the elements that are needed to attach this
vdev to the media device.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: rockchip/vpu: Use v4l2_apply_frmsize_constraints() where appropriate
Boris Brezillon [Tue, 28 May 2019 17:02:20 +0000 (13:02 -0400)]
media: rockchip/vpu: Use v4l2_apply_frmsize_constraints() where appropriate

Use the v4l2_apply_frmsize_constraints() helper instead of open-coding
it.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-common: Add an helper to apply frmsize constraints
Boris Brezillon [Tue, 28 May 2019 17:02:18 +0000 (13:02 -0400)]
media: v4l2-common: Add an helper to apply frmsize constraints

The rockchip VPU driver is open-coding this logic which seems pretty
generic. Let's provide an helper to apply the min/max and alignment
constraints on width/height.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-common: Fix v4l2_fill_pixfmt[_mp]() prototypes
Boris Brezillon [Tue, 28 May 2019 17:02:17 +0000 (13:02 -0400)]
media: v4l2-common: Fix v4l2_fill_pixfmt[_mp]() prototypes

Width/height and 4CC formats are expressed using u32 types everywhere,
let's fix the v4l2_fill_pixfmt[_mp]() prototypes to do the same.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cec-adap: fix regression in ping sanity check
Hans Verkuil [Wed, 29 May 2019 08:22:15 +0000 (04:22 -0400)]
media: cec-adap: fix regression in ping sanity check

Commit b6c96e156825 inadvertently also dropped the 'msg->len > 1' test
from the preceding sanity check. This caused compliance test failures.

Fixes: b6c96e156825 ("media: cec: allow any initiator for Ping and Image/Text View On")

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: saa7164: fix remove_proc_entry warning
Kefeng Wang [Mon, 27 May 2019 12:14:55 +0000 (08:14 -0400)]
media: saa7164: fix remove_proc_entry warning

if saa7164_proc_create() fails, saa7164_fini() will trigger a warning,

name 'saa7164'
WARNING: CPU: 1 PID: 6311 at fs/proc/generic.c:672 remove_proc_entry+0x1e8/0x3a0
  ? remove_proc_entry+0x1e8/0x3a0
  ? try_stop_module+0x7b/0x240
  ? proc_readdir+0x70/0x70
  ? rcu_read_lock_sched_held+0xd7/0x100
  saa7164_fini+0x13/0x1f [saa7164]
  __x64_sys_delete_module+0x30c/0x480
  ? __ia32_sys_delete_module+0x480/0x480
  ? __x64_sys_clock_gettime+0x11e/0x1c0
  ? __x64_sys_timer_create+0x1a0/0x1a0
  ? trace_hardirqs_off_caller+0x40/0x180
  ? do_syscall_64+0x18/0x450
  do_syscall_64+0x9f/0x450
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fix it by checking the return of proc_create_single() before
calling remove_proc_entry().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: use 0444 instead of S_IRUGO]
[hverkuil-cisco@xs4all.nl: use pr_info instead of KERN_INFO]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mc-device.c: don't memset __user pointer contents
Hans Verkuil [Mon, 27 May 2019 09:31:13 +0000 (05:31 -0400)]
media: mc-device.c: don't memset __user pointer contents

You can't memset the contents of a __user pointer. Instead, call copy_to_user to
copy links.reserved (which is zeroed) to the user memory.

This fixes this sparse warning:

SPARSE:drivers/media/mc/mc-device.c drivers/media/mc/mc-device.c:521:16:  warning: incorrect type in argument 1 (different address spaces)

Fixes: f49308878d720 ("media: media_device_enum_links32: clean a reserved field")

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: media-ioc-enum-links.rst: fix incorrect reserved field documentation
Hans Verkuil [Mon, 27 May 2019 09:11:32 +0000 (05:11 -0400)]
media: media-ioc-enum-links.rst: fix incorrect reserved field documentation

The reserved field array for struct media_link_desc has length 2, not 4.

And the reserved field array of struct media_links_enum was never documented
at all.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mtk-vcodec: fix leaked of_node references
Wen Yang [Mon, 6 May 2019 07:05:17 +0000 (03:05 -0400)]
media: mtk-vcodec: fix leaked of_node references

The call to of_find_device_by_node returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:60:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 38, but without a corresponding object release within this function.
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:63:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 38, but without a corresponding object release within this function.
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:72:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 38, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: mtk-vpu: fix leaked of_node references
Wen Yang [Mon, 6 May 2019 07:05:16 +0000 (03:05 -0400)]
media: mtk-vpu: fix leaked of_node references

The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
drivers/media/platform/mtk-vpu/mtk_vpu.c:477:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 464, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: Address several coding style issues
Mauro Carvalho Chehab [Tue, 28 May 2019 21:42:56 +0000 (17:42 -0400)]
media: cx25840: Address several coding style issues

As we did a major change on this file, let's take the moment
to cleanup several coding style issues on it.

This patch was partially done with the help of two tools:

./scripts/checkpatch.pl --fix-inplace --strict
astyle --indent=tab=8 --style=linux

But manually adjusted in order to fit our style.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cxusb: fix several coding style issues
Mauro Carvalho Chehab [Tue, 28 May 2019 21:42:57 +0000 (17:42 -0400)]
media: cxusb: fix several coding style issues

As this driver had a major change, let's take the opportunity
and do some coding style cleanup, in order to make it compliant
with Kernel's style.

This patch was partially done with the help of two tools:

./scripts/checkpatch.pl --fix-inplace --strict
astyle --indent=tab=8 --style=linux

But manually adjusted in order to fit our style.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cxusb-analog: Fix some coding style issues
Mauro Carvalho Chehab [Tue, 28 May 2019 20:12:53 +0000 (16:12 -0400)]
media: cxusb-analog: Fix some coding style issues

This is a new file, so the best moment to make it to follow
Kernel coding style is now.

This patch was partially generated with:

./scripts/checkpatch.pl --fix-inplace --strict -f drivers/media/usb/dvb-usb/cxusb-analog.c

And manually checked and adjusted to avoid any warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging: allegro: cleanup two warnings
Mauro Carvalho Chehab [Wed, 29 May 2019 13:43:02 +0000 (09:43 -0400)]
media: staging: allegro: cleanup two warnings

Sparse complains about two issues when building with i386
and COMPILE_TEST:

drivers/staging/media/allegro-dvt/allegro-core.c:1849:36: warning: constant 0xffffffff00000000UL is so big it is unsigned long long
drivers/staging/media/allegro-dvt/allegro-core.c:865:24: error: incompatible types in comparison expression (different type sizes)

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: allegro-dvt: fix build failure
Hans Verkuil [Wed, 29 May 2019 12:46:32 +0000 (08:46 -0400)]
media: allegro-dvt: fix build failure

nal-h264.h is a local header, not a global one. Use "" instead of <>.

Fixed this compile error:

  CC      drivers/staging/media/allegro-dvt/nal-h264.o
drivers/staging/media/allegro-dvt/nal-h264.c:24:10: fatal error: nal-h264.h: No such file or directory
 #include <nal-h264.h>
          ^~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: videobuf2-vmalloc: get_userptr: buffers are always writable
Hans Verkuil [Thu, 4 Apr 2019 13:15:00 +0000 (09:15 -0400)]
media: videobuf2-vmalloc: get_userptr: buffers are always writable

In vb2_vmalloc_get_userptr() the framevector is created with the
'write' argument set to false when vb2_create_framevec() is called
for OUTPUT buffers. So the pages are marked as read-only.

However, userspace will write to these buffers since it will fill
in the data to output. Since get_userptr is only called if the userptr
of the queued buffer has changed since the last time that same buffer
was queued, this will fail when the buffer contents is updated and the
buffer is queued again.

E.g., userspace fills buffer 1 with the output video and queues it.
The first time get_userptr is called and the pages are grabbed and
pinned in memory and marked read-only. The second time buffer 1 is
filled with different video data and queued again. Since the userptr
hasn't changed the get_userptr() callback isn't called again. Since
the pages were marked as read-only the new contents isn't updated.

Just always call vb2_create_framevec() with FOLL_WRITE to always
allow writing to the buffers.

Using USERPTR streaming with OUTPUT devices is almost never done. And
when it is done it is via v4l2-compliance and a driver like vim2m. But
since v4l2-compliance doesn't actually inspect the capture buffer and
compare it to the original output buffer, this issue was never noticed.

But the vicodec driver actually needs to parse the bitstream in the
OUTPUT buffers and any errors there will be immediately noticed. So
this time v4l2-compliance failed the USERPTR streaming test.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: allegro: add SPS/PPS nal unit writer
Michael Tretter [Tue, 28 May 2019 17:11:20 +0000 (13:11 -0400)]
media: allegro: add SPS/PPS nal unit writer

The allegro hardware encoder does not write SPS/PPS nal units into the
encoded video stream. Therefore, we need to write the units in software.

The implementation follows Rec. ITU-T H.264 (04/2017) to allow to
convert between a C struct and the RBSP representation of the SPS and
PPS nal units.

The allegro driver writes the nal units into the v4l2 capture buffer in
front of the actual video data which is written at an offset by the IP
core. The remaining gap is filled with a filler nal unit.

[hverkuil-cisco@xs4all.nl: added missing @dev description for nal_h264_read_sps()]
[mchehab+samsung@kernel.org: removed uneeded "-ccflags-y $(src)" from Makefile]

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: allegro: add Allegro DVT video IP core driver
Michael Tretter [Tue, 28 May 2019 17:11:19 +0000 (13:11 -0400)]
media: allegro: add Allegro DVT video IP core driver

Add a V4L2 mem-to-mem driver for Allegro DVT video IP cores as found in
the EV family of the Xilinx ZynqMP SoC. The Zynq UltraScale+ Device
Technical Reference Manual uses the term VCU (Video Codec Unit) for the
encoder, decoder and system integration block.

This driver takes care of interacting with the MicroBlaze MCU that
controls the actual IP cores. The IP cores and MCU are integrated in the
FPGA. The xlnx_vcu driver is responsible for configuring the clocks and
providing information about the codec configuration.

The driver currently only supports the H.264 video encoder.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: Add vendor prefix for allegro
Michael Tretter [Tue, 28 May 2019 17:11:18 +0000 (13:11 -0400)]
media: dt-bindings: media: Add vendor prefix for allegro

Add vendor prefix for Allegro DVT, a provider of H.264/AVC, H.265/HEVC,
AVS2, VP9 and AV1 compliance test suites and H.264/AVC, H.265/HEVC, and
VP9 encoder, codec and decoder hardware (RTL) IPs.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: dt-bindings: media: document allegro-dvt bindings
Michael Tretter [Tue, 28 May 2019 17:11:17 +0000 (13:11 -0400)]
media: dt-bindings: media: document allegro-dvt bindings

Add device-tree bindings for the Allegro DVT video IP core found on the
Xilinx ZynqMP EV family.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: videobuf2-v4l2: set last_buffer_dequeued in dqbuf
Hans Verkuil [Tue, 28 May 2019 17:11:16 +0000 (13:11 -0400)]
media: videobuf2-v4l2: set last_buffer_dequeued in dqbuf

last_buffer_dequeued was set to true in __fill_v4l2_buffer, but this
is called for qbuf as well. Move it to vb2_dqbuf.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cedrus: Add H264 decoding support
Maxime Ripard [Fri, 24 May 2019 09:20:31 +0000 (05:20 -0400)]
media: cedrus: Add H264 decoding support

Introduce some basic H264 decoding support in cedrus. So far, only the
baseline profile videos have been tested, and some more advanced features
used in higher profiles are not even implemented.

Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: pixfmt: Add H264_SLICE_RAW format documentation
Maxime Ripard [Fri, 24 May 2019 09:20:30 +0000 (05:20 -0400)]
media: pixfmt: Add H264_SLICE_RAW format documentation

The H264_SLICE_RAW format introduced before is meant for stateless
decoders that will need the H264 parsed slice data without the start code.

Let's document it.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: pixfmt: Add H264 Slice format
Maxime Ripard [Fri, 24 May 2019 09:20:29 +0000 (05:20 -0400)]
media: pixfmt: Add H264 Slice format

The H264_SLICE_RAW format is meant to hold the parsed slice data without
the start code. This will be needed by stateless decoders.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: uapi: Add H264 low-level decoder API compound controls.
Pawel Osciak [Fri, 24 May 2019 09:20:28 +0000 (05:20 -0400)]
media: uapi: Add H264 low-level decoder API compound controls.

Stateless video codecs will require both the H264 metadata and slices in
order to be able to decode frames.

This introduces the definitions for the structures used to pass the
metadata from the userspace to the kernel.

[hverkuil-cisco@xs4all.nl: add space after . in ".For"]
[hverkuil-cisco@xs4all.nl: sync v4l2_ctrl_h264_decode_params struct layout with header]

Co-developed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Pawel Osciak <posciak@chromium.org>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cedrus: Allow different mod clock rates
Jernej Skrabec [Sat, 18 May 2019 17:44:15 +0000 (13:44 -0400)]
media: cedrus: Allow different mod clock rates

Some VPU variants may run at higher clock speeds. They actually need
extra speed to be capable of decoding more complex codecs like HEVC or
bigger image sizes (4K).

Expand variant structure with mod_rate information.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: use v4l2_m2m_buf_copy_metadata
Philipp Zabel [Fri, 12 Apr 2019 15:51:34 +0000 (11:51 -0400)]
media: coda: use v4l2_m2m_buf_copy_metadata

Use v4l2_m2m2_buf_copy_metadata to let BIT encoder contexts copy buffer
field, timestamp, timestamp flags, and optionally timecode.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: add lockdep asserts
Philipp Zabel [Fri, 12 Apr 2019 15:51:33 +0000 (11:51 -0400)]
media: coda: add lockdep asserts

coda_command_sync, coda_hw_reset, and __coda_start_decoding
all expect to be called under the coda_mutex device lock.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: add decoder MPEG-2 profile and level controls
Philipp Zabel [Mon, 27 May 2019 12:20:11 +0000 (08:20 -0400)]
media: coda: add decoder MPEG-2 profile and level controls

The MPEG-2 decoder firmware reports profile and level indication that
can be used to set V4L2 MPEG-2 profile and level controls

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: v4l2-ctrl: add MPEG-2 profile and level controls
Philipp Zabel [Wed, 24 Apr 2019 10:43:47 +0000 (06:43 -0400)]
media: v4l2-ctrl: add MPEG-2 profile and level controls

Add MPEG-2 CID definitions for profiles and levels defined in ITU-T Rec.
H.262.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: coda: add decoder MPEG-4 profile and level controls
Philipp Zabel [Mon, 27 May 2019 12:19:22 +0000 (08:19 -0400)]
media: coda: add decoder MPEG-4 profile and level controls

The MPEG-4 decoder firmware reports profile and level indication values
that can be used to update V4L2 MPEG-4 profile and level controls.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cxusb: add raw mode support for Medion MD95700
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:59 +0000 (12:16 -0400)]
media: cxusb: add raw mode support for Medion MD95700

This adds raw (unprocessed) BT.656 stream capturing support for the analog
part of Medion 95700.
It can be enabled by setting CXUSB_EXTENDEDMODE_CAPTURE_RAW flag in
parm.capture.extendedmode passed to VIDIOC_S_PARM.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cxusb: add analog mode support for Medion MD95700
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:58 +0000 (12:16 -0400)]
media: cxusb: add analog mode support for Medion MD95700

This patch adds support for analog part of Medion 95700 in the cxusb
driver.

What works:
* Video capture at various sizes with sequential fields,
* Input switching (TV Tuner, Composite, S-Video),
* TV and radio tuning,
* Video standard switching and auto detection,
* Radio mode switching (stereo / mono),
* Unplugging while capturing,
* DVB / analog coexistence.

What does not work yet:
* Audio,
* VBI,
* Picture controls.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: remove left-over commented-out debug message]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cxusb: implement Medion MD95700 digital / analog coexistence
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:57 +0000 (12:16 -0400)]
media: cxusb: implement Medion MD95700 digital / analog coexistence

This patch prepares cxusb driver for supporting the analog part of
Medion 95700 (previously only the digital - DVB - mode was supported).

Specifically, it adds support for:
* switching the device between analog and digital modes of operation,
* enforcing that only one mode is active at the same time due to hardware
limitations.

Actual implementation of the analog mode will be provided by the next
commit.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: set_fmt operation should clamp out-of-range picture sizes
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:56 +0000 (12:16 -0400)]
media: cx25840: set_fmt operation should clamp out-of-range picture sizes

According to V4L2 API set_fmt subdev operation should not return an error
on out-of-range picture sizes, the values should be clamped instead to the
supported range.

The cx25840 datasheet says that the chip is capable of scaling down the
picture width and height, respectively, 16 and 8 times.
These values agree with what the old implementation enforced.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: add pin to pad mapping and output format configuration
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:55 +0000 (12:16 -0400)]
media: cx25840: add pin to pad mapping and output format configuration

This commit adds pin to pad mapping and output format configuration support
in CX2584x-series chips to cx25840 driver.

This functionality is then used to allow disabling ivtv-specific hacks and
configuration values (called a "generic mode"), so cx25840 driver can be
used for other devices not needing them without risking compatibility
problems.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: implement g_std operation
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:54 +0000 (12:16 -0400)]
media: cx25840: implement g_std operation

This commit implements g_std operation in cx25840 driver by returning the
last set video standard.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: g_std operation really implements querystd operation
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:53 +0000 (12:16 -0400)]
media: cx25840: g_std operation really implements querystd operation

cx25840 driver g_std operation queries the currently detected video signal,
however this is what querystd operation should do, so let's rename the
handler.

None of the existing cx25840 driver users ever called the g_std operation,
one of them calls querystd on each of its subdevs but then the result is
only used to implement VIDIOC_QUERYSTD (as it should).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: cx25840: don't open-code cx25840_reset() inside cx25840_load_fw()
Maciej S. Szmigiero [Mon, 29 Apr 2019 16:16:52 +0000 (12:16 -0400)]
media: cx25840: don't open-code cx25840_reset() inside cx25840_load_fw()

cx25840_load_fw() does the same thing as cx25840_reset(), only keeps
"is_initialized" flag so any further invocation of this function besides
the first one is a NOP.
Let's just call cx25840_reset() directly from cx25840_load_fw() instead of
open coding it there.

While we are at it, let's also improve comments about cx25840_load_fw()
so they are current and in the proper style (one of them even referred to a
non-existing cx25840 init operation).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Change imx7_csi_enable() to void
Fabio Estevam [Sat, 4 May 2019 14:40:27 +0000 (10:40 -0400)]
media: imx7-media-csi: Change imx7_csi_enable() to void

imx7_csi_enable() always return 0 and its return value is never checked,
so convert it to void.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Check the return value from clk_prepare_enable()
Fabio Estevam [Sat, 4 May 2019 14:40:26 +0000 (10:40 -0400)]
media: imx7-media-csi: Check the return value from clk_prepare_enable()

clk_prepare_enable() may fail, so we should better check its return value
and propagate it in the case of error.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Remove unneeded break
Fabio Estevam [Sat, 4 May 2019 14:40:24 +0000 (10:40 -0400)]
media: imx7-media-csi: Remove unneeded break

Remove unneeded 'break' right after the 'return' statement as
pointed out by checkpatch.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Propagate the correct error for devm_request_irq()
Fabio Estevam [Sat, 4 May 2019 14:40:23 +0000 (10:40 -0400)]
media: imx7-media-csi: Propagate the correct error for devm_request_irq()

In the case of devm_request_irq() failure, let's propagate the real error
code instead of a fake one.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Propagate the correct error for platform_get_irq()
Fabio Estevam [Sat, 4 May 2019 14:40:22 +0000 (10:40 -0400)]
media: imx7-media-csi: Propagate the correct error for platform_get_irq()

In the case of platform_get_irq() failure, let's propagate the real error
code instead of a fake one.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Use devm_platform_ioremap_resource()
Fabio Estevam [Sat, 4 May 2019 14:40:21 +0000 (10:40 -0400)]
media: imx7-media-csi: Use devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify the code a bit.

While at it, propagate the real error value in case of
devm_platform_ioremap_resource() failure.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: imx7-media-csi: Acquire a single clock
Fabio Estevam [Sat, 4 May 2019 14:40:20 +0000 (10:40 -0400)]
media: imx7-media-csi: Acquire a single clock

As per the i.MX7D Reference Manual only the MCLK is used for
the CSI block, so only handle this single clock.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: Don't set driver data for v4l2_dev
Steve Longerbeam [Fri, 10 May 2019 21:50:12 +0000 (17:50 -0400)]
media: staging/imx: Don't set driver data for v4l2_dev

The media device is already available via multiple methods, there is no
need to set driver data for v4l2_dev to the media device.

In imx_media_link_notify(), get media device from link->graph_obj.mdev.

In imx_media_capture_device_register(), get media device from
v4l2_dev->mdev.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: Improve pipeline searching
Steve Longerbeam [Fri, 10 May 2019 21:50:11 +0000 (17:50 -0400)]
media: staging/imx: Improve pipeline searching

Export find_pipeline_pad(), renaming to imx_media_pipeline_pad(), and
extend its functionality to allow searching for video devices in the
enabled pipeline in addition to sub-devices.

As part of this:

- Rename imx_media_find_mipi_csi2_channel() to
  imx_media_pipeline_csi2_channel().

- Remove imx_media_find_upstream_pad(), it is redundant now.

- Rename imx_media_find_upstream_subdev() to imx_media_pipeline_subdev()
  with an additional boolean argument for searching upstream or downstream.

- Add imx_media_pipeline_video_device() which is analogous to
  imx_media_pipeline_subdev() but searches for video devices.

- Remove imxmd pointer arg from all of the functions above, it was
  never used in those functions. With that change the i.MX5/6 CSI,
  VDIC, and IC sub-devices no longer require the media_device.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: Re-organize modules
Steve Longerbeam [Fri, 10 May 2019 21:50:10 +0000 (17:50 -0400)]
media: staging/imx: Re-organize modules

Re-organize modules, and which objects are linked into those modules, so
that:

- imx6-media (renamed from imx-media) is the media driver module for
  imx5/6 only, and has no symbol exports.

- imx6-media-csi (renamed from imx-media-csi) is the subdev driver
  module for imx5/6 CSI. It is now linked direcly with imx-media-fim,
  since only the imx5/6 CSI makes use of the frame interval monitor.

- imx-media-common now only contains common code between imx5/6 and imx7
  media drivers. It contains imx-media-utils, imx-media-of,
  imx-media-dev-common, and imx-media-capture. In order to acheive that,
  some functions common to imx5/6 and imx7 have been moved out of
  imx-media-dev.c and into imx-media-dev-common.c.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5 years agomedia: staging/imx: Remove capture_device_set_format
Steve Longerbeam [Fri, 10 May 2019 21:50:09 +0000 (17:50 -0400)]
media: staging/imx: Remove capture_device_set_format

Don't propagate the source pad format to the connected capture device.
It's now the responsibility of userspace to call VIDIOC_S_FMT on the
capture device to ensure the capture format and compose rectangle
are compatible with the connected source. To check this, validate
the capture format with the source before streaming starts.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>