Re: [PATCH] Mediatek staging: Use individual config flags in Makefile

2019-01-09 Thread George Hilliard
On Thu, Jan 10, 2019 at 12:39 AM Greg KH  wrote:
>
> On Thu, Jan 10, 2019 at 12:26:28AM -0700, thirtythreefo...@gmail.com wrote:
> > From: George Hilliard 
> >
> > These drivers are useful on other MT76xx SoCs, which have compatible
> > peripherals.  The drivers are selectable in Kconfig, but they were
> > quietly excluded from the build because the SOC_MT7621 chip was not
> > selected.  So, make the main staging Makefile use the same flags as
> > everything else for these drivers.
> >
> > I have personally confirmed that the mt7621-spi driver works on the
> > MT7688, which was what prompted this change.
> >
> > Cc: de...@driverdev.osuosl.org
> > Cc: Matthias Brugger 
> > Cc: John Crispin 
> > Signed-off-by: George Hilliard 
> > ---
> >  drivers/staging/Makefile | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
> > index 5868631e8f1b..50c980c16c0d 100644
> > --- a/drivers/staging/Makefile
> > +++ b/drivers/staging/Makefile
> > @@ -42,10 +42,10 @@ obj-$(CONFIG_BCM2835_VCHIQ)   += vc04_services/
> >  obj-$(CONFIG_DRM_VBOXVIDEO)  += vboxvideo/
> >  obj-$(CONFIG_PI433)  += pi433/
> >  obj-$(CONFIG_SOC_MT7621) += mt7621-pci/
> > -obj-$(CONFIG_SOC_MT7621) += mt7621-pinctrl/
> > -obj-$(CONFIG_SOC_MT7621) += mt7621-spi/
> > +obj-$(CONFIG_PINCTRL_RT2880) += mt7621-pinctrl/
> > +obj-$(CONFIG_SPI_MT7621) += mt7621-spi/
> >  obj-$(CONFIG_SOC_MT7621) += mt7621-dma/
>
> What about the DMA driver?

It has two separate drivers in it, actually. Briefly:

config DMA_RALINK
  tristate "RALINK DMA support"
  depends on RALINK && !SOC_RT288X

config MTK_HSDMA
  tristate "MTK HSDMA support"
  depends on RALINK && SOC_MT7621

I think they should be broken out into two separate directories to
make them amenable to this change.  Should I do this?

>
> > -obj-$(CONFIG_SOC_MT7621) += mt7621-mmc/
> > +obj-$(CONFIG_MTK_MMC)+= mt7621-mmc/
> >  obj-$(CONFIG_SOC_MT7621) += mt7621-eth/
> >  obj-$(CONFIG_SOC_MT7621) += mt7621-dts/
>
> And these drivers?  Why not change all of these at once?

mt7621-dts ignored because it truly does depend on the MT7621 (only
thing in there is the device tree for the GnuBee).

mt7621-eth ignored because I forgot it.  I'll add to the next revision.

>
> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Mediatek staging: Use individual config flags in Makefile

2019-01-09 Thread Greg KH
On Thu, Jan 10, 2019 at 12:26:28AM -0700, thirtythreefo...@gmail.com wrote:
> From: George Hilliard 
> 
> These drivers are useful on other MT76xx SoCs, which have compatible
> peripherals.  The drivers are selectable in Kconfig, but they were
> quietly excluded from the build because the SOC_MT7621 chip was not
> selected.  So, make the main staging Makefile use the same flags as
> everything else for these drivers.
> 
> I have personally confirmed that the mt7621-spi driver works on the
> MT7688, which was what prompted this change.
> 
> Cc: de...@driverdev.osuosl.org
> Cc: Matthias Brugger 
> Cc: John Crispin 
> Signed-off-by: George Hilliard 
> ---
>  drivers/staging/Makefile | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
> index 5868631e8f1b..50c980c16c0d 100644
> --- a/drivers/staging/Makefile
> +++ b/drivers/staging/Makefile
> @@ -42,10 +42,10 @@ obj-$(CONFIG_BCM2835_VCHIQ)   += vc04_services/
>  obj-$(CONFIG_DRM_VBOXVIDEO)  += vboxvideo/
>  obj-$(CONFIG_PI433)  += pi433/
>  obj-$(CONFIG_SOC_MT7621) += mt7621-pci/
> -obj-$(CONFIG_SOC_MT7621) += mt7621-pinctrl/
> -obj-$(CONFIG_SOC_MT7621) += mt7621-spi/
> +obj-$(CONFIG_PINCTRL_RT2880) += mt7621-pinctrl/
> +obj-$(CONFIG_SPI_MT7621) += mt7621-spi/
>  obj-$(CONFIG_SOC_MT7621) += mt7621-dma/

What about the DMA driver?

> -obj-$(CONFIG_SOC_MT7621) += mt7621-mmc/
> +obj-$(CONFIG_MTK_MMC)+= mt7621-mmc/
>  obj-$(CONFIG_SOC_MT7621) += mt7621-eth/
>  obj-$(CONFIG_SOC_MT7621) += mt7621-dts/

And these drivers?  Why not change all of these at once?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Mediatek staging: Use individual config flags in Makefile

2019-01-09 Thread thirtythreeforty
From: George Hilliard 

These drivers are useful on other MT76xx SoCs, which have compatible
peripherals.  The drivers are selectable in Kconfig, but they were
quietly excluded from the build because the SOC_MT7621 chip was not
selected.  So, make the main staging Makefile use the same flags as
everything else for these drivers.

I have personally confirmed that the mt7621-spi driver works on the
MT7688, which was what prompted this change.

Cc: de...@driverdev.osuosl.org
Cc: Matthias Brugger 
Cc: John Crispin 
Signed-off-by: George Hilliard 
---
 drivers/staging/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 5868631e8f1b..50c980c16c0d 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -42,10 +42,10 @@ obj-$(CONFIG_BCM2835_VCHIQ) += vc04_services/
 obj-$(CONFIG_DRM_VBOXVIDEO)+= vboxvideo/
 obj-$(CONFIG_PI433)+= pi433/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-pci/
-obj-$(CONFIG_SOC_MT7621)   += mt7621-pinctrl/
-obj-$(CONFIG_SOC_MT7621)   += mt7621-spi/
+obj-$(CONFIG_PINCTRL_RT2880)   += mt7621-pinctrl/
+obj-$(CONFIG_SPI_MT7621)   += mt7621-spi/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-dma/
-obj-$(CONFIG_SOC_MT7621)   += mt7621-mmc/
+obj-$(CONFIG_MTK_MMC)  += mt7621-mmc/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-eth/
 obj-$(CONFIG_SOC_MT7621)   += mt7621-dts/
 obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Peter Robinson
> > I get difference results with 5.0-rc1 but neither of the above apps
> > work either, will follow up based on the rest of the thread there.
> >
>
> My first step with Raspbian is to enable the Camera interface which results 
> into an appending of the following lines to config.txt:
>
> start_x=1
> gpu_mem=128
>
> AFAIK a smaller value for gpu_mem wont work. Please provide your settings 
> which results in this crash.

OK with that, plus my 4.20.1 kernel (and the 09/01/19 firmware) I'm
starting to get somewhere.

I can get a picture with the qv4l2 app ;-)

If I try with cheese I get the following two crashes, I then tried
with qv4l2 again (no reboot) and got the final crash, basically once
cheese/gstreamer pokes it tht's it and it doesn't come back. The
"Comm: v4l2src0:src" are the cheese/gstreamer crash.

[   26.013706] vchiq: module is from the staging directory, the
quality is unknown, you have been warned.
[   26.040943] vchiq: vchiq_init_state: slot_zero = 415842fa, is_master = 0
[   26.937936] media: Linux media interface: v0.10
[   27.052339] videodev: Linux video capture interface: v2.00
[   27.351732] snd_bcm2835: module is from the staging directory, the
quality is unknown, you have been warned.
[   27.385975] bcm2835_audio bcm2835_audio: card created with 8 channels
[   27.406702] bcm2835_v4l2: module is from the staging directory, the
quality is unknown, you have been warned.
[   28.059932] bcm2835-v4l2: scene mode selected 0, was 0
[   28.061098] bcm2835-v4l2: V4L2 device registered as video0 - stills
mode > 1280x720
[   28.074773] bcm2835-v4l2: Broadcom 2835 MMAL video capture ver 0.0.2 loaded.
[   78.307961] bcm2835_audio bcm2835_audio: vchi message timeout, msg=5
[  138.790296] bcm2835-v4l2: Failed to enable capture port - error -1.
Disabling camera port again
[  138.818456] [ cut here ]
[  138.823246] WARNING: CPU: 2 PID: 1464 at
drivers/media/common/videobuf2/videobuf2-core.c:1471
vb2_start_streaming+0xb4/0x12c [videobuf2_common]
[  138.836377] Modules linked in: fuse ip6t_rpfilter ip6t_REJECT
nf_reject_ipv6 xt_conntrack ebtable_nat ip6table_nat nf_nat_ipv6
ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_nat_ipv4
nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack
nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c ip_set nfnetlink
ebtable_filter ebtables ip6table_filter ip6_tables cmac bnep sunrpc
vfat fat vc4 snd_soc_core bcm2835_v4l2(C) snd_bcm2835(C)
videobuf2_vmalloc ac97_bus snd_pcm_dmaengine videobuf2_memops
videobuf2_v4l2 snd_seq videobuf2_common snd_seq_device snd_pcm
v4l2_common videodev brcmfmac media snd_timer snd brcmutil soundcore
drm_kms_helper cfg80211 drm hci_uart fb_sys_fops syscopyarea btqca
sysfillrect btbcm joydev sysimgblt btintel bluetooth raspberrypi_hwmon
ecdh_generic rfkill vchiq(C) bcm2835_thermal bcm2835_rng bcm2835_wdt
leds_gpio cpufreq_dt lz4 lz4_compress zram hid_logitech_hidpp
hid_logitech_dj smsc95xx usbnet mii mmc_block sdhci_iproc dwc2
crc32_arm_ce sdhci_pltfm
[  138.836522]  gpio_raspberrypi_exp udc_core sdhci pwm_bcm2835
i2c_bcm2835 bcm2835 bcm2835_dma phy_generic
[  138.934289] CPU: 2 PID: 1464 Comm: v4l2src0:src Tainted: G
C4.20.1-200.fc29.armv7hl #1
[  138.943729] Hardware name: BCM2835
[  138.947196] [] (unwind_backtrace) from []
(show_stack+0x18/0x1c)
[  138.955058] [] (show_stack) from []
(dump_stack+0x80/0xa0)
[  138.962390] [] (dump_stack) from [] (__warn+0xdc/0xf8)
[  138.969366] [] (__warn) from []
(warn_slowpath_null+0x40/0x4c)
[  138.977070] [] (warn_slowpath_null) from []
(vb2_start_streaming+0xb4/0x12c [videobuf2_common])
[  138.987713] [] (vb2_start_streaming [videobuf2_common])
from [] (vb2_core_streamon+0x110/0x138 [videobuf2_common])
[  139.54] [] (vb2_core_streamon [videobuf2_common])
from [] (__video_do_ioctl+0x35c/0x494 [videodev])
[  139.011453] [] (__video_do_ioctl [videodev]) from
[] (video_usercopy+0x508/0x5d4 [videodev])
[  139.021827] [] (video_usercopy [videodev]) from
[] (vfs_ioctl+0x28/0x3c)
[  139.030391] [] (vfs_ioctl) from []
(do_vfs_ioctl+0x8c/0x838)
[  139.037896] [] (do_vfs_ioctl) from []
(ksys_ioctl+0x58/0x74)
[  139.045398] [] (ksys_ioctl) from []
(ret_fast_syscall+0x0/0x54)
[  139.053160] Exception stack(0xd0b2ffa8 to 0xd0b2fff0)
[  139.058281] ffa0:    aa812138 001e
40045612 01658708 b590cd10
[  139.066577] ffc0:  aa812138 ab8af99c 0036 0020
b6f388f8 01658700 aa80cc90
[  139.074869] ffe0: b5b4dcec a69fa974 ab8786f4 b590cd1c
[  139.080031] ---[ end trace eed7fb71749a2e2c ]---
[  139.211923] bcm2835-v4l2: vidioc_s_fmt_vid_cap device busy
[  177.331656] bcm2835-v4l2: Failed to enable capture port - error -1.
Disabling camera port again
[  177.362943] [ cut here ]
[  177.367736] WARNING: CPU: 1 PID: 1531 at
drivers/media/common/videobuf2/videobuf2-core.c:1471
vb2_start_streaming+0xb4/0x12c [videobuf2_common]
[  177.380847] Modules linked in: fuse ip6t_rpfilter ip6t_REJECT
nf_reject_ipv6 xt_conntrack

Re: [PATCH] staging: rtl8723bs: Mark ACPI table declaration as used

2019-01-09 Thread Greg KH
On Wed, Jan 09, 2019 at 04:19:30PM -0800, Nick Desaulniers wrote:
> Digging up an old thread to point out I was wrong:
> 
> On Thu, Sep 27, 2018 at 1:08 PM Nick Desaulniers
>  wrote:
> > > This is not a million-little-commits problem; more like 2 drivers in
> > > the whole tree have this problem.
> > >
> > > Note that this change that Nathan has DOES NOT need to applied to
> > > every driver that uses MODULE_DEVICE_TABLE.  Only when the struct has
> > > no other references other than JUST being passed to
> > > MODULE_DEVICE_TABLE() is this a problem.  For an allyesconfig, I only
> > > see 2 instances of this case in the whole tree:
> > >
> > > https://github.com/ClangBuiltLinux/linux/issues/169 <- this patch is 
> > > addressing
> > > https://github.com/ClangBuiltLinux/linux/issues/178 <- waiting on the
> > > results of this patch
> > >
> > > If you're ok with this change to two drivers, then:
> > > Reviewed-by: Nick Desaulniers 
> 
> I just landed a fix for this in Clang
> (https://reviews.llvm.org/rL350776) which will ship soon in Clang 8.
> Sedat helped test this patch and reported that it removed 41
> false-negative warnings
> https://github.com/ClangBuiltLinux/linux/issues/232#issuecomment-440006399

Great, thanks for letting me know.  Can I revert this patch?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Peter Robinson
> > Hi Stefan,
> >
> ...
> >
> > I get difference results with 5.0-rc1 but neither of the above apps
> > work either, will follow up based on the rest of the thread there.
> >
>
> My first step with Raspbian is to enable the Camera interface which results 
> into an appending of the following lines to config.txt:
>
> start_x=1
> gpu_mem=128
>
> AFAIK a smaller value for gpu_mem wont work. Please provide your settings 
> which results in this crash.

start_x=1
gpu_mem=64
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Stefan Wahren


> Peter Robinson  hat am 10. Januar 2019 um 06:09 
> geschrieben:
> 
> 
> Hi Stefan,
> 
...
> 
> I get difference results with 5.0-rc1 but neither of the above apps
> work either, will follow up based on the rest of the thread there.
> 

My first step with Raspbian is to enable the Camera interface which results 
into an appending of the following lines to config.txt:

start_x=1
gpu_mem=128

AFAIK a smaller value for gpu_mem wont work. Please provide your settings which 
results in this crash.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vboxvideo: vbox_main: Remove unnecessary local variable

2019-01-09 Thread Sidong Yang
Removed unnecessary local variable in have_hgsmi_mode_hints.
The result of hgsmi_query_conf should be directly compared without
assigning to local variable.

Signed-off-by: Sidong Yang 
---
 drivers/staging/vboxvideo/vbox_main.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c 
b/drivers/staging/vboxvideo/vbox_main.c
index e1fb70a42d32..62a69fde7435 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -170,18 +170,15 @@ static void vbox_accel_fini(struct vbox_private *vbox)
 static bool have_hgsmi_mode_hints(struct vbox_private *vbox)
 {
u32 have_hints, have_cursor;
-   int ret;
 
-   ret = hgsmi_query_conf(vbox->guest_pool,
-  VBOX_VBVA_CONF32_MODE_HINT_REPORTING,
-  &have_hints);
-   if (ret)
+   if (hgsmi_query_conf(vbox->guest_pool,
+VBOX_VBVA_CONF32_MODE_HINT_REPORTING,
+&have_hints))
return false;
 
-   ret = hgsmi_query_conf(vbox->guest_pool,
-  VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING,
-  &have_cursor);
-   if (ret)
+   if (hgsmi_query_conf(vbox->guest_pool,
+VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING,
+&have_cursor))
return false;
 
return have_hints == VINF_SUCCESS && have_cursor == VINF_SUCCESS;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Peter Robinson
 Hi Dave,

> > > This patch series improves the load/unload of bcm2835 camera and audio
> > > drivers. It has been tested with Raspberry Pi 3 B and a camera module V1.
> > >
> > > This series based on current linux-next and Phil Elwell's series 
> > > ("Improve VCHIQ
> > > cache line size handling"). After Nicolas' series ("staging: 
> > > vc04_services:
> > > Some dead code removal") has been applied, i will rebase my series.
> >
> > I tried testing this series applied to 4.20 with the camera module. I
> > tried with qv4l2 (from v4l-utils) and using cheese, which in turn uses
> > gstreamer. I basically get the same crash for both options. Desktop is
> > LXDE on 32 bit Fedora 29.
> >
> > I've not yet tried with 5.0-rc1 but it looks like it has this patch
> > series and some other bits for the vchiq drivers in staging.
>
> I'm trying to sort the patches I have on our kernel tree and get them
> in a shape to get merged to staging.
> I've built for 5.0.0-rc1 and also see the same error using:
> v4l2-ctl -v width=640,height=480,pixelformat=YU12
> v4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=300
>
> It's three independent things:
> - The firmware has failed the failed to enable the camera for reasons unknown.

OK, with the extended firmware enabled I get the following boot
messages before trying to access the camera:

[   27.541690] bcm2835_v4l2: module is from the staging directory, the
quality is unknown, you have been warned.
[   28.203301] bcm2835-v4l2: scene mode selected 0, was 0
[   28.203882] bcm2835-v4l2: V4L2 device registered as video0 - stills
mode > 1280x720
[   28.219128] bcm2835-v4l2: Broadcom 2835 MMAL video capture ver 0.0.2 loaded.

Any idea what I should be seeing besides this if it enables it
properly, I get different errors if I don't have extended firmware or
not enough memory.

With Stefan's upstream commit 4cc357c500d (staging: bcm2835-camera:
Add hint about possible faulty config) he reports "Not enough GPU
mem?" but I wonder if it's more accurate to report that the wrong
firmware is loaded, I've managed to get that error if I have enough
memory and aren't don't have "start_x=1" (or have start_x=10).

BTW what is enough memory? It seems 32Mb should be enough, tried with
the same results with 64Mb too but I've not found anything explicit
about features vs gpu_mem, until I've started looking at the camera
we've set it to 16Mb due to using the open vc4 driver, but as other
things start to come along like the camera, and presumably accelerated
video decoding, this seems to affect those.

As a side note it would be a useful debug feature from a support PoV
if the following line could also note which firmware is loaded:

[8.087691] raspberrypi-firmware soc:firmware: Attached to firmware
from 2019-01-09 20:07

Something like "attached to extended/reduced/whatecer firmware from -XX-XX"

> - The error path then hasn't returned all the buffers to videobuf2,
> hence the warning from videobuf2-core.c:1468
> - The driver has then tried to pass some buffers to MMAL / VCHI which
> tries adding them to an invalid list.
>
> I'm investigating why the firmware is failing to enable the camera
> initially, and then look at cleaning up the error handling.

OK, let me know when you've got something you want me to test.

Peter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Peter Robinson
Hi Stefan,

> > > But why didn't you applied the series which was actually applied to 
> > > mainline?
> > > Did you apply the rest of Phil's DT series as mentioned in the cover 
> > > letter?
> >
> > I'm fairly certain I have Phil's "Improve VCHIQ cache line size
> > handling" patch series applied if that's the one you mean, I will
> > check (I'm currently dealing with 4 different kernels for maintenance
> > so I'm sorry if my memory isn't exact).
>
> That's correct. Btw you will need a recent raspberrypi-firmware (iirc since 
> 10/2018), too.

For reference I was using 1ea8781 from 18/12/2018, I noticed there's a
new one that fixes colour issues with the cameres.

Given I couldn't work out exactly which random patch set I had for the
test kernel I've now moved to a 4.20.1 with cacheline and this patch
series. I still get the same series of crash there from just running
qv4l2. I get a blank OpenGL window (could be something unrelated with
the vc4 driver), and the same issue with cheese.

[   74.723451] bcm2835_audio bcm2835_audio: vchi message timeout, msg=5
[  118.512917] bcm2835-v4l2: Failed enabling camera, ret -2
[  118.518379] bcm2835-v4l2: Failed to enable camera
[  118.523228] [ cut here ]
[  118.528002] WARNING: CPU: 3 PID: 1470 at
drivers/media/common/videobuf2/videobuf2-core.c:1471
vb2_start_streaming+0xb4/0x12c [videobuf2_common]
[  118.541098] Modules linked in: fuse ip6t_rpfilter ip6t_REJECT
nf_reject_ipv6 xt_conntrack ebtable_nat ip6table_nat nf_nat_ipv6
ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_nat_ipv4
nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack
nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c ip_set nfnetlink
ebtable_filter ebtables cmac ip6table_filter ip6_tables bnep sunrpc
vfat fat vc4 snd_soc_core ac97_bus bcm2835_v4l2(C) snd_pcm_dmaengine
snd_bcm2835(C) videobuf2_vmalloc snd_seq videobuf2_memops
videobuf2_v4l2 snd_seq_device videobuf2_common snd_pcm v4l2_common
videodev snd_timer snd media brcmfmac soundcore drm_kms_helper
brcmutil drm hci_uart cfg80211 fb_sys_fops btqca syscopyarea btbcm
joydev sysfillrect btintel sysimgblt bluetooth raspberrypi_hwmon
ecdh_generic rfkill bcm2835_thermal bcm2835_rng bcm2835_wdt vchiq(C)
leds_gpio cpufreq_dt lz4 lz4_compress zram hid_logitech_hidpp
hid_logitech_dj smsc95xx usbnet mii mmc_block dwc2 sdhci_iproc
sdhci_pltfm udc_core
[  118.541261]  gpio_raspberrypi_exp crc32_arm_ce sdhci pwm_bcm2835
bcm2835 i2c_bcm2835 bcm2835_dma phy_generic
[  118.639009] CPU: 3 PID: 1470 Comm: qv4l2 Tainted: G C
 4.20.1-200.fc29.armv7hl #1
[  118.647828] Hardware name: BCM2835
[  118.651296] [] (unwind_backtrace) from []
(show_stack+0x18/0x1c)
[  118.659156] [] (show_stack) from []
(dump_stack+0x80/0xa0)
[  118.666488] [] (dump_stack) from [] (__warn+0xdc/0xf8)
[  118.673466] [] (__warn) from []
(warn_slowpath_null+0x40/0x4c)
[  118.681168] [] (warn_slowpath_null) from []
(vb2_start_streaming+0xb4/0x12c [videobuf2_common])
[  118.691810] [] (vb2_start_streaming [videobuf2_common])
from [] (vb2_core_streamon+0x110/0x138 [videobuf2_common])
[  118.704152] [] (vb2_core_streamon [videobuf2_common])
from [] (__video_do_ioctl+0x35c/0x494 [videodev])
[  118.715546] [] (__video_do_ioctl [videodev]) from
[] (video_usercopy+0x508/0x5d4 [videodev])
[  118.725923] [] (video_usercopy [videodev]) from
[] (vfs_ioctl+0x28/0x3c)
[  118.734487] [] (vfs_ioctl) from []
(do_vfs_ioctl+0x8c/0x838)
[  118.741990] [] (do_vfs_ioctl) from []
(ksys_ioctl+0x58/0x74)
[  118.749495] [] (ksys_ioctl) from []
(ret_fast_syscall+0x0/0x54)
[  118.757259] Exception stack(0xd940dfa8 to 0xd940dff0)
[  118.762382] dfa0:   d47c8700 b5f1e000 000c
40045612 befb42a0 0001
[  118.770678] dfc0: d47c8700 b5f1e000 40045612 0036 b5e81e40
000c b6f41508 
[  118.778970] dfe0: befb42a0 befb4290 b5f07804 b5bdb1f0
[  118.784155] ---[ end trace 4c04f89544a1aee9 ]---
[  132.329586] bcm2835-v4l2: Failed enabling camera, ret -2
[  132.335008] bcm2835-v4l2: Failed to enable camera
[  132.339826] [ cut here ]
[  132.344555] WARNING: CPU: 3 PID: 1470 at
drivers/media/common/videobuf2/videobuf2-core.c:1471
vb2_start_streaming+0xb4/0x12c [videobuf2_common]
[  132.357629] Modules linked in: fuse ip6t_rpfilter ip6t_REJECT
nf_reject_ipv6 xt_conntrack ebtable_nat ip6table_nat nf_nat_ipv6
ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_nat_ipv4
nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack
nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c ip_set nfnetlink
ebtable_filter ebtables cmac ip6table_filter ip6_tables bnep sunrpc
vfat fat vc4 snd_soc_core ac97_bus bcm2835_v4l2(C) snd_pcm_dmaengine
snd_bcm2835(C) videobuf2_vmalloc snd_seq videobuf2_memops
videobuf2_v4l2 snd_seq_device videobuf2_common snd_pcm v4l2_common
videodev snd_timer snd media brcmfmac soundcore drm_kms_helper
brcmutil drm hci_uart cfg80211 fb_sys_fops btqca syscopyarea btbcm
joydev sysfillrect btintel sysimgblt bluetooth rasp

RE: [PATCH v2] Drivers: hv: vmbus: Expose counters for interrupts and full conditions

2019-01-09 Thread Dexuan Cui
> From: Michael Kelley 
> Sent: Saturday, January 5, 2019 1:01 PM
> > From: Kimberly Brown   Sent: Friday, January 4,
>  > 2019 8:35 PM
> >
> >  static inline void set_channel_pending_send_size(struct vmbus_channel *c,
> >  u32 size)
> >  {
> > +   if (size) {
> > +   ++c->out_full_total;
> > +
> > +   if (!c->out_full_flag) {
> > +   ++c->out_full_first;
> > +   c->out_full_flag = true;
> > +   }
> > +   } else {
> > +   c->out_full_flag = false;
> > +   }
> > +
> > c->outbound.ring_buffer->pending_send_sz = size;
> >  }
> >
> 
> I think there may be an atomicity problem with the above code.  I looked
> in the hv_sock code, and didn't see any locks being held when
> set_channel_pending_send_size() is called.   The original code doesn't need
> a lock because it is just storing a single value into pending_send_sz.
>
> In the similar code in hv_ringbuffer_write(), the ring buffer spin lock is 
> held
> while the counts are incremented and the out_full_flag is maintained, so all 
> is
> good there.  But some locking may be needed here.  Dexuan knows the
> hv_sock
> code best and can comment on whether there is any higher level
> synchronization
> that prevents multiple threads from running the above code on the same
> channel.
> Even if there is such higher level synchronization, this code probably 
> shouldn't
> depend on it for correctness.
> 
> Michael

Yes, there is indeed a higher level per-"sock" lock, e.g. in the code path
vsock_stream_sendmsg() -> vsock_stream_has_space() -> 
transport->stream_has_space() -> hvs_stream_has_space() -> 
hvs_set_channel_pending_send_size(), we acquire the lock by
lock_sock(sk) at the beginning of vsock_stream_sendmsg(), and call
release_sock(sk) at the end of the function.

So we don't have an atomicity issue here for hv_sock, which is the only user
of set_channel_pending_send_size(), so far.

Thanks,
-- Dexuan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2] Drivers: hv: vmbus: Expose counters for interrupts and full conditions

2019-01-09 Thread Dexuan Cui
> From: Kimberly Brown 
> Sent: Friday, January 4, 2019 8:35 PM

...
> +What:
> /sys/bus/vmbus/devices//channels//intr_in_full
> +Date:   January 2019
> +KernelVersion:  4.21

There is no 4.21 version: see https://lkml.org/lkml/2019/1/6/178  :-)

Thanks!
-- Dexuan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH][re-post] vmbus: fix subchannel removal

2019-01-09 Thread Sasha Levin

On Wed, Jan 09, 2019 at 08:56:06PM +, Dexuan Cui wrote:


The changes to split ring allocation from open/close, broke
the cleanup of subchannels. This resulted in problems using
uio on network devices because the subchannel was left behind
when the network device was unbound.

The cause was in the disconnect logic which used list splice
to move the subchannel list into a local variable. This won't
work because the subchannel list is needed later during the
process of the rescind messages (relid2channel).

The fix is to just leave the subchannel list in place
which is what the original code did. The list is cleaned
up later when the host rescind is processed.

Without the fix, we have a lot of "hang" issues in netvsc when we
try to change the NIC's MTU, set the number of channels, etc.

Fixes: ae6935ed7d42 ("vmbus: split ring buffer allocation from open")
Cc: sta...@vger.kernel.org
Signed-off-by: Stephen Hemminger 
Signed-off-by: Dexuan Cui 


Queued, thank you.

--
Thanks,
Sasha
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][re-post] vmbus: fix subchannel removal

2019-01-09 Thread Dexuan Cui


The changes to split ring allocation from open/close, broke
the cleanup of subchannels. This resulted in problems using
uio on network devices because the subchannel was left behind
when the network device was unbound.

The cause was in the disconnect logic which used list splice
to move the subchannel list into a local variable. This won't
work because the subchannel list is needed later during the
process of the rescind messages (relid2channel).

The fix is to just leave the subchannel list in place
which is what the original code did. The list is cleaned
up later when the host rescind is processed.

Without the fix, we have a lot of "hang" issues in netvsc when we
try to change the NIC's MTU, set the number of channels, etc.

Fixes: ae6935ed7d42 ("vmbus: split ring buffer allocation from open")
Cc: sta...@vger.kernel.org
Signed-off-by: Stephen Hemminger 
Signed-off-by: Dexuan Cui 

---

The patch was firstly posted on Dec-7 2018:
https://www.spinics.net/lists/linux-driver-devel/msg120802.html
but it looks it's neglected.

Now let me rebase it to v5.0-rc1: the line "channel->num_sc = 0;"
in the original patch must be removed due to
4d3c5c69191f ("Drivers: hv: vmbus: Remove the useless API 
vmbus_get_outgoing_channel()")

When the patch is backported to v4.20.1, there will be a conflict because
v4.20.1 doesn't have 4d3c5c69191f. I suggest we cherry-pick 4d3c5c69191f
into v4.20.1, before we backport this patch.

 drivers/hv/channel.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index ce0ba20..bea4c98 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -701,19 +701,12 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
 int vmbus_disconnect_ring(struct vmbus_channel *channel)
 {
struct vmbus_channel *cur_channel, *tmp;
-   unsigned long flags;
-   LIST_HEAD(list);
int ret;
 
if (channel->primary_channel != NULL)
return -EINVAL;
 
-   /* Snapshot the list of subchannels */
-   spin_lock_irqsave(&channel->lock, flags);
-   list_splice_init(&channel->sc_list, &list);
-   spin_unlock_irqrestore(&channel->lock, flags);
-
-   list_for_each_entry_safe(cur_channel, tmp, &list, sc_list) {
+   list_for_each_entry_safe(cur_channel, tmp, &channel->sc_list, sc_list) {
if (cur_channel->rescind)
wait_for_completion(&cur_channel->rescind_event);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: imx-csi: Input connections to CSI should be optional

2019-01-09 Thread Steve Longerbeam
Some imx platforms do not have fwnode connections to all CSI input
ports, and should not be treated as an error. This includes the
imx6q SabreAuto, which has no connections to ipu1_csi1 and ipu2_csi0.
Return -ENOTCONN in imx_csi_parse_endpoint() so that v4l2-fwnode
endpoint parsing will not treat an unconnected CSI input port as
an error.

Fixes: c893500a16baf ("media: imx: csi: Register a subdev notifier")

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 4223f8d418ae..30b1717982ae 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1787,7 +1787,7 @@ static int imx_csi_parse_endpoint(struct device *dev,
  struct v4l2_fwnode_endpoint *vep,
  struct v4l2_async_subdev *asd)
 {
-   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
+   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
 }
 
 static int imx_csi_async_register(struct csi_priv *priv)
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 07/11] media: imx-csi: Allow skipping odd chroma rows for YVU420

2019-01-09 Thread Steve Longerbeam
Skip writing U/V components to odd rows for YVU420 in addition to
YUV420 and NV12.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 604d0bd24389..6f1e11b8a7cb 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -452,6 +452,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
passthrough_bits = 16;
break;
case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_NV12:
burst_size = (image.pix.width & 0x3f) ?
 ((image.pix.width & 0x1f) ?
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 02/11] gpu: ipu-csi: Swap fields according to input/output field types

2019-01-09 Thread Steve Longerbeam
The function ipu_csi_init_interface() was inverting the F-bit for
NTSC case, in the CCIR_CODE_1/2 registers. The result being that
for NTSC bottom-top field order, the CSI would swap fields and
capture in top-bottom order.

Instead, base field swap on the field order of the input to the CSI,
and the field order of the requested output. If the input/output
fields are sequential but different, swap fields, otherwise do
not swap. This requires passing both the input and output mbus
frame formats to ipu_csi_init_interface().

Move this code to a new private function ipu_csi_set_bt_interlaced_codes()
that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and
possibly interlaced BT.1120 in the future).

When detecting input video standard from the input frame width/height,
make sure to double height if input field type is alternate, since
in that case input height only includes lines for one field.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
Acked-by: Philipp Zabel 
---
Changes since v5:
- Convert to const the infmt, outfmt, and mbus_cfg pointer args to
  ipu_csi_init_interface(), suggested by Philipp Zabel.
- Bring back if_fmt local var and don't copy outfmt to local stack in
  csi_setup(), suggested by Philipp.

Changes since v4:
- Cleaned up some convoluted code in ipu_csi_init_interface(), suggested
  by Philipp.
- Fixed a regression in csi_setup(), caught by Philipp.
---
 drivers/gpu/ipu-v3/ipu-csi.c  | 126 +++---
 drivers/staging/media/imx/imx-media-csi.c |   7 +-
 include/video/imx-ipu-v3.h|   5 +-
 3 files changed, 89 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index aa0e30a2ba18..d1e575571a8d 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -325,12 +325,21 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config 
*cfg, u32 mbus_code,
return 0;
 }
 
+/* translate alternate field mode based on given standard */
+static inline enum v4l2_field
+ipu_csi_translate_field(enum v4l2_field field, v4l2_std_id std)
+{
+   return (field != V4L2_FIELD_ALTERNATE) ? field :
+   ((std & V4L2_STD_525_60) ?
+V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB);
+}
+
 /*
  * Fill a CSI bus config struct from mbus_config and mbus_framefmt.
  */
 static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
-struct v4l2_mbus_config *mbus_cfg,
-struct v4l2_mbus_framefmt *mbus_fmt)
+   const struct v4l2_mbus_config *mbus_cfg,
+   const struct v4l2_mbus_framefmt *mbus_fmt)
 {
int ret;
 
@@ -374,22 +383,76 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config 
*csicfg,
return 0;
 }
 
+static int
+ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi,
+   const struct v4l2_mbus_framefmt *infmt,
+   const struct v4l2_mbus_framefmt *outfmt,
+   v4l2_std_id std)
+{
+   enum v4l2_field infield, outfield;
+   bool swap_fields;
+
+   /* get translated field type of input and output */
+   infield = ipu_csi_translate_field(infmt->field, std);
+   outfield = ipu_csi_translate_field(outfmt->field, std);
+
+   /*
+* Write the H-V-F codes the CSI will match against the
+* incoming data for start/end of active and blanking
+* field intervals. If input and output field types are
+* sequential but not the same (one is SEQ_BT and the other
+* is SEQ_TB), swap the F-bit so that the CSI will capture
+* field 1 lines before field 0 lines.
+*/
+   swap_fields = (V4L2_FIELD_IS_SEQUENTIAL(infield) &&
+  V4L2_FIELD_IS_SEQUENTIAL(outfield) &&
+  infield != outfield);
+
+   if (!swap_fields) {
+   /*
+* Field0BlankEnd  = 110, Field0BlankStart  = 010
+* Field0ActiveEnd = 100, Field0ActiveStart = 000
+* Field1BlankEnd  = 111, Field1BlankStart  = 011
+* Field1ActiveEnd = 101, Field1ActiveStart = 001
+*/
+   ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+   ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
+   } else {
+   dev_dbg(csi->ipu->dev, "capture field swap\n");
+
+   /* same as above but with F-bit inverted */
+   ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+   ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2);
+   }
+
+   ipu_csi_write(csi, 0xFF, CSI_CCIR_CODE_3);
+
+   return 0;
+}
+
+
 int ipu_csi_init_interface(struct ipu_csi *csi,
-  struct v4l2_mbus_config *mbus_cfg,
-  struct v4l2_mbus_framefm

[PATCH v8 10/11] media: imx: Allow interweave with top/bottom lines swapped

2019-01-09 Thread Steve Longerbeam
Allow sequential->interlaced interweaving but with top/bottom
lines swapped to the output buffer.

This can be accomplished by adding one line length to IDMAC output
channel address, with a negative line length for the interlace offset.

This is to allow the seq-bt -> interlaced-bt transformation, where
bottom lines are still dominant (older in time) but with top lines
first in the interweaved output buffer.

With this support, the CSI can now allow seq-bt at its source pads,
e.g. the following transformations are allowed in CSI from sink to
source:

seq-tb -> seq-bt
seq-bt -> seq-bt
alternate -> seq-bt

Suggested-by: Philipp Zabel 
Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
Changes since v4:
- Removed interweave_offset and replace with boolean interweave_swap,
  suggested by Philipp Zabel.
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 25 +
 drivers/staging/media/imx/imx-media-csi.c   | 40 ++---
 2 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index cf76b0432371..33ada6612fee 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -106,6 +106,7 @@ struct prp_priv {
u32 frame_sequence; /* frame sequence counter */
bool last_eof;  /* waiting for last EOF at stream off */
bool nfb4eof;/* NFB4EOF encountered during streaming */
+   bool interweave_swap; /* swap top/bottom lines when interweaving */
struct completion last_eof_comp;
 };
 
@@ -235,6 +236,9 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct 
ipuv3_channel *ch)
if (ipu_idmac_buffer_is_ready(ch, priv->ipu_buf_num))
ipu_idmac_clear_buffer(ch, priv->ipu_buf_num);
 
+   if (priv->interweave_swap && ch == priv->out_ch)
+   phys += vdev->fmt.fmt.pix.bytesperline;
+
ipu_cpmem_set_buffer(ch, priv->ipu_buf_num, phys);
 }
 
@@ -376,8 +380,9 @@ static int prp_setup_channel(struct prp_priv *priv,
 * the IDMAC output channel.
 */
interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) &&
-   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) &&
-   channel == priv->out_ch;
+   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field);
+   priv->interweave_swap = interweave &&
+   image.pix.field == V4L2_FIELD_INTERLACED_BT;
 
if (rot_swap_width_height) {
swap(image.pix.width, image.pix.height);
@@ -388,6 +393,11 @@ static int prp_setup_channel(struct prp_priv *priv,
(image.pix.width * outcc->bpp) >> 3;
}
 
+   if (priv->interweave_swap && channel == priv->out_ch) {
+   /* start interweave scan at 1st top line (2nd line) */
+   image.rect.top = 1;
+   }
+
image.phys0 = addr0;
image.phys1 = addr1;
 
@@ -396,8 +406,8 @@ static int prp_setup_channel(struct prp_priv *priv,
 * channels for planar 4:2:0 (but not when enabling IDMAC
 * interweaving, they are incompatible).
 */
-   if (!interweave && (channel == priv->out_ch ||
-   channel == priv->rot_out_ch)) {
+   if ((channel == priv->out_ch && !interweave) ||
+   channel == priv->rot_out_ch) {
switch (image.pix.pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
@@ -424,8 +434,11 @@ static int prp_setup_channel(struct prp_priv *priv,
if (rot_mode)
ipu_cpmem_set_rotation(channel, rot_mode);
 
-   if (interweave)
-   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
+   if (interweave && channel == priv->out_ch)
+   ipu_cpmem_interlaced_scan(channel,
+ priv->interweave_swap ?
+ -image.pix.bytesperline :
+ image.pix.bytesperline,
  image.pix.pixelformat);
 
ret = ipu_ic_task_idma_init(priv->ic, channel,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 8537ecb7dd17..555aa45e02e3 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -114,6 +114,7 @@ struct csi_priv {
u32 frame_sequence; /* frame sequence counter */
bool last_eof;   /* waiting for last EOF at stream off */
bool nfb4eof;/* NFB4EOF encountered during streaming */
+   bool interweave_swap; /* swap top/bottom lines when interweaving */
struct completion last_eof_comp;
 };
 
@@ -286,6 +287,9 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
if (ipu_idmac_buffer_is_ready(priv->idmac_ch, priv->ipu_buf_num))
ipu_idmac_clear_buffer(priv->idmac_ch, priv->ipu_buf_num);
 
+   i

[PATCH v8 09/11] media: imx-csi: Move crop/compose reset after filling default mbus fields

2019-01-09 Thread Steve Longerbeam
If caller passes un-initialized field type V4L2_FIELD_ANY to CSI
sink pad, the reset CSI crop window would not be correct, because
the crop window depends on a valid input field type. To fix move
the reset of crop and compose windows to after the call to
imx_media_fill_default_mbus_fields().

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 27 ---
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 6f1e11b8a7cb..8537ecb7dd17 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1409,19 +1409,6 @@ static void csi_try_fmt(struct csi_priv *priv,
  W_ALIGN, &sdformat->format.height,
  MIN_H, MAX_H, H_ALIGN, S_ALIGN);
 
-   /* Reset crop and compose rectangles */
-   crop->left = 0;
-   crop->top = 0;
-   crop->width = sdformat->format.width;
-   crop->height = sdformat->format.height;
-   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
-   crop->height *= 2;
-   csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
-   compose->left = 0;
-   compose->top = 0;
-   compose->width = crop->width;
-   compose->height = crop->height;
-
*cc = imx_media_find_mbus_format(sdformat->format.code,
 CS_SEL_ANY, true);
if (!*cc) {
@@ -1437,6 +1424,20 @@ static void csi_try_fmt(struct csi_priv *priv,
imx_media_fill_default_mbus_fields(
&sdformat->format, infmt,
priv->active_output_pad == CSI_SRC_PAD_DIRECT);
+
+   /* Reset crop and compose rectangles */
+   crop->left = 0;
+   crop->top = 0;
+   crop->width = sdformat->format.width;
+   crop->height = sdformat->format.height;
+   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
+   crop->height *= 2;
+   csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
+   compose->left = 0;
+   compose->top = 0;
+   compose->width = crop->width;
+   compose->height = crop->height;
+
break;
}
 }
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 06/11] media: imx: interweave and odd-chroma-row skip are incompatible

2019-01-09 Thread Steve Longerbeam
If IDMAC interweaving is enabled in a write channel, the channel must
write the odd chroma rows for 4:2:0 formats. Skipping writing the odd
chroma rows produces corrupted captured 4:2:0 images when interweave
is enabled.

Reported-by: Krzysztof HaƂasa 
Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +++--
 drivers/staging/media/imx/imx-media-csi.c   | 8 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 1a03d4c9d7b8..cf76b0432371 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -391,12 +391,17 @@ static int prp_setup_channel(struct prp_priv *priv,
image.phys0 = addr0;
image.phys1 = addr1;
 
-   if (channel == priv->out_ch || channel == priv->rot_out_ch) {
+   /*
+* Skip writing U and V components to odd rows in the output
+* channels for planar 4:2:0 (but not when enabling IDMAC
+* interweaving, they are incompatible).
+*/
+   if (!interweave && (channel == priv->out_ch ||
+   channel == priv->rot_out_ch)) {
switch (image.pix.pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_NV12:
-   /* Skip writing U and V components to odd rows */
ipu_cpmem_skip_odd_chroma_rows(channel);
break;
}
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 10945cbdbd71..604d0bd24389 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -457,8 +457,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
 ((image.pix.width & 0x1f) ?
  ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64;
passthrough_bits = 16;
-   /* Skip writing U and V components to odd rows */
-   ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
+   /*
+* Skip writing U and V components to odd rows (but not
+* when enabling IDMAC interweaving, they are incompatible).
+*/
+   if (!interweave)
+   ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
break;
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 05/11] media: imx-csi: Double crop height for alternate fields at sink

2019-01-09 Thread Steve Longerbeam
If the incoming sink field type is alternate, the reset crop height
and crop height bounds must be set to twice the incoming height,
because in alternate field mode, upstream will report only the
lines for a single field, and the CSI captures the whole frame.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index e3a4f39dbf73..10945cbdbd71 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1142,6 +1142,8 @@ static void csi_try_crop(struct csi_priv *priv,
 struct v4l2_mbus_framefmt *infmt,
 struct v4l2_fwnode_endpoint *upstream_ep)
 {
+   u32 in_height;
+
crop->width = min_t(__u32, infmt->width, crop->width);
if (crop->left + crop->width > infmt->width)
crop->left = infmt->width - crop->width;
@@ -1149,6 +1151,10 @@ static void csi_try_crop(struct csi_priv *priv,
crop->left &= ~0x3;
crop->width &= ~0x7;
 
+   in_height = infmt->height;
+   if (infmt->field == V4L2_FIELD_ALTERNATE)
+   in_height *= 2;
+
/*
 * FIXME: not sure why yet, but on interlaced bt.656,
 * changing the vertical cropping causes loss of vertical
@@ -1158,12 +1164,12 @@ static void csi_try_crop(struct csi_priv *priv,
if (upstream_ep->bus_type == V4L2_MBUS_BT656 &&
(V4L2_FIELD_HAS_BOTH(infmt->field) ||
 infmt->field == V4L2_FIELD_ALTERNATE)) {
-   crop->height = infmt->height;
-   crop->top = (infmt->height == 480) ? 2 : 0;
+   crop->height = in_height;
+   crop->top = (in_height == 480) ? 2 : 0;
} else {
-   crop->height = min_t(__u32, infmt->height, crop->height);
-   if (crop->top + crop->height > infmt->height)
-   crop->top = infmt->height - crop->height;
+   crop->height = min_t(__u32, in_height, crop->height);
+   if (crop->top + crop->height > in_height)
+   crop->top = in_height - crop->height;
}
 }
 
@@ -1403,6 +1409,8 @@ static void csi_try_fmt(struct csi_priv *priv,
crop->top = 0;
crop->width = sdformat->format.width;
crop->height = sdformat->format.height;
+   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
+   crop->height *= 2;
csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
compose->left = 0;
compose->top = 0;
@@ -1530,6 +1538,8 @@ static int csi_get_selection(struct v4l2_subdev *sd,
sel->r.top = 0;
sel->r.width = infmt->width;
sel->r.height = infmt->height;
+   if (infmt->field == V4L2_FIELD_ALTERNATE)
+   sel->r.height *= 2;
break;
case V4L2_SEL_TGT_CROP:
sel->r = *crop;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 08/11] media: imx: vdic: rely on VDIC for correct field order

2019-01-09 Thread Steve Longerbeam
prepare_vdi_in_buffers() was setting up the dma pointers as if the
VDIC is always programmed to receive the fields in bottom-top order,
i.e. as if ipu_vdi_set_field_order() only programs BT order in the VDIC.
But that's not true, ipu_vdi_set_field_order() is working correctly.

So fix prepare_vdi_in_buffers() to give the VDIC the fields in whatever
order they were received by the video source, and rely on the VDIC to
sort out which is top and which is bottom.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-vdic.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c
index 482250d47e7c..4a890714193e 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -219,26 +219,18 @@ static void __maybe_unused prepare_vdi_in_buffers(struct 
vdic_priv *priv,
 
switch (priv->fieldtype) {
case V4L2_FIELD_SEQ_TB:
-   prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0);
-   curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs;
-   next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
-   break;
case V4L2_FIELD_SEQ_BT:
prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + fs;
curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs;
break;
+   case V4L2_FIELD_INTERLACED_TB:
case V4L2_FIELD_INTERLACED_BT:
+   case V4L2_FIELD_INTERLACED:
prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + is;
curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is;
break;
-   default:
-   /* assume V4L2_FIELD_INTERLACED_TB */
-   prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0);
-   curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is;
-   next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
-   break;
}
 
ipu_cpmem_set_buffer(priv->vdi_in_ch_p, 0, prev_phys);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 04/11] media: imx: Fix field negotiation

2019-01-09 Thread Steve Longerbeam
IDMAC interlaced scan, a.k.a. interweave, should be enabled in the
IDMAC output channels only if the IDMAC output pad field type is
'seq-bt' or 'seq-tb', and field type at the capture interface is
'interlaced*'.

V4L2_FIELD_HAS_BOTH() macro should not be used on the input to determine
enabling interlaced/interweave scan. That macro includes the 'interlaced'
field types, and in those cases the data is already interweaved with
top/bottom field lines.

The CSI will capture whole frames when the source specifies alternate
field mode. So the CSI also enables interweave for alternate input
field type and the field type at capture interface is interlaced.

Fix the logic for setting field type in try_fmt in CSI entity.
The behavior should be:

- No restrictions on field type at sink pad.

- At the output pads, allow sequential fields in TB order, if the sink pad
  field type is sequential or alternate. Otherwise passthrough the field
  type from sink to source pad.

Move this logic to new function csi_try_field().

These changes result in the following allowed field transformations
from CSI sink -> source pads (all other field types at sink are passed
through to source):

seq-tb -> seq-tb
seq-bt -> seq-tb
alternate -> seq-tb

In a future patch, the CSI sink -> source will allow:

seq-tb -> seq-bt
seq-bt -> seq-bt
alternate -> seq-bt

This will require supporting interweave with top/bottom line swapping.
Until then seq-bt is not allowed at the CSI source pad because there is
no way to swap top/bottom lines when interweaving to INTERLACED_BT --
note that despite the name, INTERLACED_BT is top-bottom order in memory.
The BT in this case refers to field dominance: the bottom lines are
older in time than the top lines.

The capture interface device allows selecting IDMAC interweave by
choosing INTERLACED_TB if the CSI/PRPENCVF source pad is seq-tb and
INTERLACED_BT if the source pad is seq-bt (for future support of seq-bt).

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c   | 21 --
 drivers/staging/media/imx/imx-media-capture.c | 14 
 drivers/staging/media/imx/imx-media-csi.c | 64 ++-
 3 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index af7224846bd5..1a03d4c9d7b8 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -354,12 +354,13 @@ static int prp_setup_channel(struct prp_priv *priv,
 {
struct imx_media_video_dev *vdev = priv->vdev;
const struct imx_media_pixfmt *outcc;
-   struct v4l2_mbus_framefmt *infmt;
+   struct v4l2_mbus_framefmt *outfmt;
unsigned int burst_size;
struct ipu_image image;
+   bool interweave;
int ret;
 
-   infmt = &priv->format_mbus[PRPENCVF_SINK_PAD];
+   outfmt = &priv->format_mbus[PRPENCVF_SRC_PAD];
outcc = vdev->cc;
 
ipu_cpmem_zero(channel);
@@ -369,6 +370,15 @@ static int prp_setup_channel(struct prp_priv *priv,
image.rect.width = image.pix.width;
image.rect.height = image.pix.height;
 
+   /*
+* If the field type at capture interface is interlaced, and
+* the output IDMAC pad is sequential, enable interweave at
+* the IDMAC output channel.
+*/
+   interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) &&
+   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) &&
+   channel == priv->out_ch;
+
if (rot_swap_width_height) {
swap(image.pix.width, image.pix.height);
swap(image.rect.width, image.rect.height);
@@ -409,9 +419,7 @@ static int prp_setup_channel(struct prp_priv *priv,
if (rot_mode)
ipu_cpmem_set_rotation(channel, rot_mode);
 
-   if (image.pix.field == V4L2_FIELD_NONE &&
-   V4L2_FIELD_HAS_BOTH(infmt->field) &&
-   channel == priv->out_ch)
+   if (interweave)
ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
  image.pix.pixelformat);
 
@@ -839,8 +847,7 @@ static void prp_try_fmt(struct prp_priv *priv,
infmt = __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD, sdformat->which);
 
if (sdformat->pad == PRPENCVF_SRC_PAD) {
-   if (sdformat->format.field != V4L2_FIELD_NONE)
-   sdformat->format.field = infmt->field;
+   sdformat->format.field = infmt->field;
 
prp_bound_align_output(&sdformat->format, infmt,
   priv->rot_mode);
diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index b37e1186eb2f..01ec9443de55 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -239,6 +239,20 @@ static int capture_try_fmt_vid_cap(struct file

[PATCH v8 03/11] gpu: ipu-v3: Add planar support to interlaced scan

2019-01-09 Thread Steve Longerbeam
To support interlaced scan with planar formats, cpmem SLUV must
be programmed with the correct chroma line stride. For full and
partial planar 4:2:2 (YUV422P, NV16), chroma line stride must
be doubled. For full and partial planar 4:2:0 (YUV420, YVU420, NV12),
chroma line stride must _not_ be doubled, since a single chroma line
is shared by two luma lines.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
Acked-by: Philipp Zabel 
---
 drivers/gpu/ipu-v3/ipu-cpmem.c  | 26 +++--
 drivers/staging/media/imx/imx-ic-prpencvf.c |  3 ++-
 drivers/staging/media/imx/imx-media-csi.c   |  3 ++-
 include/video/imx-ipu-v3.h  |  3 ++-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index 163fadb8a33a..d047a6867c59 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -277,9 +277,10 @@ void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 
u_off, u32 v_off)
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
 
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+  u32 pixelformat)
 {
-   u32 ilo, sly;
+   u32 ilo, sly, sluv;
 
if (stride < 0) {
stride = -stride;
@@ -290,9 +291,30 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, 
int stride)
 
sly = (stride * 2) - 1;
 
+   switch (pixelformat) {
+   case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
+   sluv = stride / 2 - 1;
+   break;
+   case V4L2_PIX_FMT_NV12:
+   sluv = stride - 1;
+   break;
+   case V4L2_PIX_FMT_YUV422P:
+   sluv = stride - 1;
+   break;
+   case V4L2_PIX_FMT_NV16:
+   sluv = stride * 2 - 1;
+   break;
+   default:
+   sluv = 0;
+   break;
+   }
+
ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
+   if (sluv)
+   ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, sluv);
 };
 EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
 
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 28f41caba05d..af7224846bd5 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -412,7 +412,8 @@ static int prp_setup_channel(struct prp_priv *priv,
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field) &&
channel == priv->out_ch)
-   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline);
+   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
+ image.pix.pixelformat);
 
ret = ipu_ic_task_idma_init(priv->ic, channel,
image.pix.width, image.pix.height,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index c2a8d9cd31b7..da4808348845 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -512,7 +512,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field))
ipu_cpmem_interlaced_scan(priv->idmac_ch,
- image.pix.bytesperline);
+ image.pix.bytesperline,
+ image.pix.pixelformat);
 
ipu_idmac_set_double_buffer(priv->idmac_ch, true);
 
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index bbc8481f567d..c887f4bee5f8 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -258,7 +258,8 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int 
stride);
 void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
 void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t 
buf);
 void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off);
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+  u32 pixelformat);
 void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id);
 int ipu_cpmem_get_burstsize(struct ipuv3_channel *ch);
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 09/11] media: imx-csi: Move crop/compose reset after filling default mbus fields

2019-01-09 Thread Steve Longerbeam
If caller passes un-initialized field type V4L2_FIELD_ANY to CSI
sink pad, the reset CSI crop window would not be correct, because
the crop window depends on a valid input field type. To fix move
the reset of crop and compose windows to after the call to
imx_media_fill_default_mbus_fields().

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 27 ---
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 6f1e11b8a7cb..8537ecb7dd17 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1409,19 +1409,6 @@ static void csi_try_fmt(struct csi_priv *priv,
  W_ALIGN, &sdformat->format.height,
  MIN_H, MAX_H, H_ALIGN, S_ALIGN);
 
-   /* Reset crop and compose rectangles */
-   crop->left = 0;
-   crop->top = 0;
-   crop->width = sdformat->format.width;
-   crop->height = sdformat->format.height;
-   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
-   crop->height *= 2;
-   csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
-   compose->left = 0;
-   compose->top = 0;
-   compose->width = crop->width;
-   compose->height = crop->height;
-
*cc = imx_media_find_mbus_format(sdformat->format.code,
 CS_SEL_ANY, true);
if (!*cc) {
@@ -1437,6 +1424,20 @@ static void csi_try_fmt(struct csi_priv *priv,
imx_media_fill_default_mbus_fields(
&sdformat->format, infmt,
priv->active_output_pad == CSI_SRC_PAD_DIRECT);
+
+   /* Reset crop and compose rectangles */
+   crop->left = 0;
+   crop->top = 0;
+   crop->width = sdformat->format.width;
+   crop->height = sdformat->format.height;
+   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
+   crop->height *= 2;
+   csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
+   compose->left = 0;
+   compose->top = 0;
+   compose->width = crop->width;
+   compose->height = crop->height;
+
break;
}
 }
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 06/11] media: imx: interweave and odd-chroma-row skip are incompatible

2019-01-09 Thread Steve Longerbeam
If IDMAC interweaving is enabled in a write channel, the channel must
write the odd chroma rows for 4:2:0 formats. Skipping writing the odd
chroma rows produces corrupted captured 4:2:0 images when interweave
is enabled.

Reported-by: Krzysztof HaƂasa 
Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +++--
 drivers/staging/media/imx/imx-media-csi.c   | 8 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 1a03d4c9d7b8..cf76b0432371 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -391,12 +391,17 @@ static int prp_setup_channel(struct prp_priv *priv,
image.phys0 = addr0;
image.phys1 = addr1;
 
-   if (channel == priv->out_ch || channel == priv->rot_out_ch) {
+   /*
+* Skip writing U and V components to odd rows in the output
+* channels for planar 4:2:0 (but not when enabling IDMAC
+* interweaving, they are incompatible).
+*/
+   if (!interweave && (channel == priv->out_ch ||
+   channel == priv->rot_out_ch)) {
switch (image.pix.pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_NV12:
-   /* Skip writing U and V components to odd rows */
ipu_cpmem_skip_odd_chroma_rows(channel);
break;
}
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 10945cbdbd71..604d0bd24389 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -457,8 +457,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
 ((image.pix.width & 0x1f) ?
  ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64;
passthrough_bits = 16;
-   /* Skip writing U and V components to odd rows */
-   ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
+   /*
+* Skip writing U and V components to odd rows (but not
+* when enabling IDMAC interweaving, they are incompatible).
+*/
+   if (!interweave)
+   ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
break;
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 04/11] media: imx: Fix field negotiation

2019-01-09 Thread Steve Longerbeam
IDMAC interlaced scan, a.k.a. interweave, should be enabled in the
IDMAC output channels only if the IDMAC output pad field type is
'seq-bt' or 'seq-tb', and field type at the capture interface is
'interlaced*'.

V4L2_FIELD_HAS_BOTH() macro should not be used on the input to determine
enabling interlaced/interweave scan. That macro includes the 'interlaced'
field types, and in those cases the data is already interweaved with
top/bottom field lines.

The CSI will capture whole frames when the source specifies alternate
field mode. So the CSI also enables interweave for alternate input
field type and the field type at capture interface is interlaced.

Fix the logic for setting field type in try_fmt in CSI entity.
The behavior should be:

- No restrictions on field type at sink pad.

- At the output pads, allow sequential fields in TB order, if the sink pad
  field type is sequential or alternate. Otherwise passthrough the field
  type from sink to source pad.

Move this logic to new function csi_try_field().

These changes result in the following allowed field transformations
from CSI sink -> source pads (all other field types at sink are passed
through to source):

seq-tb -> seq-tb
seq-bt -> seq-tb
alternate -> seq-tb

In a future patch, the CSI sink -> source will allow:

seq-tb -> seq-bt
seq-bt -> seq-bt
alternate -> seq-bt

This will require supporting interweave with top/bottom line swapping.
Until then seq-bt is not allowed at the CSI source pad because there is
no way to swap top/bottom lines when interweaving to INTERLACED_BT --
note that despite the name, INTERLACED_BT is top-bottom order in memory.
The BT in this case refers to field dominance: the bottom lines are
older in time than the top lines.

The capture interface device allows selecting IDMAC interweave by
choosing INTERLACED_TB if the CSI/PRPENCVF source pad is seq-tb and
INTERLACED_BT if the source pad is seq-bt (for future support of seq-bt).

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c   | 21 --
 drivers/staging/media/imx/imx-media-capture.c | 14 
 drivers/staging/media/imx/imx-media-csi.c | 64 ++-
 3 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index af7224846bd5..1a03d4c9d7b8 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -354,12 +354,13 @@ static int prp_setup_channel(struct prp_priv *priv,
 {
struct imx_media_video_dev *vdev = priv->vdev;
const struct imx_media_pixfmt *outcc;
-   struct v4l2_mbus_framefmt *infmt;
+   struct v4l2_mbus_framefmt *outfmt;
unsigned int burst_size;
struct ipu_image image;
+   bool interweave;
int ret;
 
-   infmt = &priv->format_mbus[PRPENCVF_SINK_PAD];
+   outfmt = &priv->format_mbus[PRPENCVF_SRC_PAD];
outcc = vdev->cc;
 
ipu_cpmem_zero(channel);
@@ -369,6 +370,15 @@ static int prp_setup_channel(struct prp_priv *priv,
image.rect.width = image.pix.width;
image.rect.height = image.pix.height;
 
+   /*
+* If the field type at capture interface is interlaced, and
+* the output IDMAC pad is sequential, enable interweave at
+* the IDMAC output channel.
+*/
+   interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) &&
+   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) &&
+   channel == priv->out_ch;
+
if (rot_swap_width_height) {
swap(image.pix.width, image.pix.height);
swap(image.rect.width, image.rect.height);
@@ -409,9 +419,7 @@ static int prp_setup_channel(struct prp_priv *priv,
if (rot_mode)
ipu_cpmem_set_rotation(channel, rot_mode);
 
-   if (image.pix.field == V4L2_FIELD_NONE &&
-   V4L2_FIELD_HAS_BOTH(infmt->field) &&
-   channel == priv->out_ch)
+   if (interweave)
ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
  image.pix.pixelformat);
 
@@ -839,8 +847,7 @@ static void prp_try_fmt(struct prp_priv *priv,
infmt = __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD, sdformat->which);
 
if (sdformat->pad == PRPENCVF_SRC_PAD) {
-   if (sdformat->format.field != V4L2_FIELD_NONE)
-   sdformat->format.field = infmt->field;
+   sdformat->format.field = infmt->field;
 
prp_bound_align_output(&sdformat->format, infmt,
   priv->rot_mode);
diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
index b37e1186eb2f..01ec9443de55 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -239,6 +239,20 @@ static int capture_try_fmt_vid_cap(struct file

[PATCH v7 10/11] media: imx: Allow interweave with top/bottom lines swapped

2019-01-09 Thread Steve Longerbeam
Allow sequential->interlaced interweaving but with top/bottom
lines swapped to the output buffer.

This can be accomplished by adding one line length to IDMAC output
channel address, with a negative line length for the interlace offset.

This is to allow the seq-bt -> interlaced-bt transformation, where
bottom lines are still dominant (older in time) but with top lines
first in the interweaved output buffer.

With this support, the CSI can now allow seq-bt at its source pads,
e.g. the following transformations are allowed in CSI from sink to
source:

seq-tb -> seq-bt
seq-bt -> seq-bt
alternate -> seq-bt

Suggested-by: Philipp Zabel 
Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
Changes since v4:
- Removed interweave_offset and replace with boolean interweave_swap,
  suggested by Philipp Zabel.
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 25 +
 drivers/staging/media/imx/imx-media-csi.c   | 40 ++---
 2 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index cf76b0432371..33ada6612fee 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -106,6 +106,7 @@ struct prp_priv {
u32 frame_sequence; /* frame sequence counter */
bool last_eof;  /* waiting for last EOF at stream off */
bool nfb4eof;/* NFB4EOF encountered during streaming */
+   bool interweave_swap; /* swap top/bottom lines when interweaving */
struct completion last_eof_comp;
 };
 
@@ -235,6 +236,9 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct 
ipuv3_channel *ch)
if (ipu_idmac_buffer_is_ready(ch, priv->ipu_buf_num))
ipu_idmac_clear_buffer(ch, priv->ipu_buf_num);
 
+   if (priv->interweave_swap && ch == priv->out_ch)
+   phys += vdev->fmt.fmt.pix.bytesperline;
+
ipu_cpmem_set_buffer(ch, priv->ipu_buf_num, phys);
 }
 
@@ -376,8 +380,9 @@ static int prp_setup_channel(struct prp_priv *priv,
 * the IDMAC output channel.
 */
interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) &&
-   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) &&
-   channel == priv->out_ch;
+   V4L2_FIELD_IS_SEQUENTIAL(outfmt->field);
+   priv->interweave_swap = interweave &&
+   image.pix.field == V4L2_FIELD_INTERLACED_BT;
 
if (rot_swap_width_height) {
swap(image.pix.width, image.pix.height);
@@ -388,6 +393,11 @@ static int prp_setup_channel(struct prp_priv *priv,
(image.pix.width * outcc->bpp) >> 3;
}
 
+   if (priv->interweave_swap && channel == priv->out_ch) {
+   /* start interweave scan at 1st top line (2nd line) */
+   image.rect.top = 1;
+   }
+
image.phys0 = addr0;
image.phys1 = addr1;
 
@@ -396,8 +406,8 @@ static int prp_setup_channel(struct prp_priv *priv,
 * channels for planar 4:2:0 (but not when enabling IDMAC
 * interweaving, they are incompatible).
 */
-   if (!interweave && (channel == priv->out_ch ||
-   channel == priv->rot_out_ch)) {
+   if ((channel == priv->out_ch && !interweave) ||
+   channel == priv->rot_out_ch) {
switch (image.pix.pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
@@ -424,8 +434,11 @@ static int prp_setup_channel(struct prp_priv *priv,
if (rot_mode)
ipu_cpmem_set_rotation(channel, rot_mode);
 
-   if (interweave)
-   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
+   if (interweave && channel == priv->out_ch)
+   ipu_cpmem_interlaced_scan(channel,
+ priv->interweave_swap ?
+ -image.pix.bytesperline :
+ image.pix.bytesperline,
  image.pix.pixelformat);
 
ret = ipu_ic_task_idma_init(priv->ic, channel,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 8537ecb7dd17..555aa45e02e3 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -114,6 +114,7 @@ struct csi_priv {
u32 frame_sequence; /* frame sequence counter */
bool last_eof;   /* waiting for last EOF at stream off */
bool nfb4eof;/* NFB4EOF encountered during streaming */
+   bool interweave_swap; /* swap top/bottom lines when interweaving */
struct completion last_eof_comp;
 };
 
@@ -286,6 +287,9 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
if (ipu_idmac_buffer_is_ready(priv->idmac_ch, priv->ipu_buf_num))
ipu_idmac_clear_buffer(priv->idmac_ch, priv->ipu_buf_num);
 
+   i

[PATCH v7 08/11] media: imx: vdic: rely on VDIC for correct field order

2019-01-09 Thread Steve Longerbeam
prepare_vdi_in_buffers() was setting up the dma pointers as if the
VDIC is always programmed to receive the fields in bottom-top order,
i.e. as if ipu_vdi_set_field_order() only programs BT order in the VDIC.
But that's not true, ipu_vdi_set_field_order() is working correctly.

So fix prepare_vdi_in_buffers() to give the VDIC the fields in whatever
order they were received by the video source, and rely on the VDIC to
sort out which is top and which is bottom.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-vdic.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c
index 482250d47e7c..4a890714193e 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -219,26 +219,18 @@ static void __maybe_unused prepare_vdi_in_buffers(struct 
vdic_priv *priv,
 
switch (priv->fieldtype) {
case V4L2_FIELD_SEQ_TB:
-   prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0);
-   curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs;
-   next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
-   break;
case V4L2_FIELD_SEQ_BT:
prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + fs;
curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs;
break;
+   case V4L2_FIELD_INTERLACED_TB:
case V4L2_FIELD_INTERLACED_BT:
+   case V4L2_FIELD_INTERLACED:
prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + is;
curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is;
break;
-   default:
-   /* assume V4L2_FIELD_INTERLACED_TB */
-   prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0);
-   curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is;
-   next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0);
-   break;
}
 
ipu_cpmem_set_buffer(priv->vdi_in_ch_p, 0, prev_phys);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 05/11] media: imx-csi: Double crop height for alternate fields at sink

2019-01-09 Thread Steve Longerbeam
If the incoming sink field type is alternate, the reset crop height
and crop height bounds must be set to twice the incoming height,
because in alternate field mode, upstream will report only the
lines for a single field, and the CSI captures the whole frame.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index e3a4f39dbf73..10945cbdbd71 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1142,6 +1142,8 @@ static void csi_try_crop(struct csi_priv *priv,
 struct v4l2_mbus_framefmt *infmt,
 struct v4l2_fwnode_endpoint *upstream_ep)
 {
+   u32 in_height;
+
crop->width = min_t(__u32, infmt->width, crop->width);
if (crop->left + crop->width > infmt->width)
crop->left = infmt->width - crop->width;
@@ -1149,6 +1151,10 @@ static void csi_try_crop(struct csi_priv *priv,
crop->left &= ~0x3;
crop->width &= ~0x7;
 
+   in_height = infmt->height;
+   if (infmt->field == V4L2_FIELD_ALTERNATE)
+   in_height *= 2;
+
/*
 * FIXME: not sure why yet, but on interlaced bt.656,
 * changing the vertical cropping causes loss of vertical
@@ -1158,12 +1164,12 @@ static void csi_try_crop(struct csi_priv *priv,
if (upstream_ep->bus_type == V4L2_MBUS_BT656 &&
(V4L2_FIELD_HAS_BOTH(infmt->field) ||
 infmt->field == V4L2_FIELD_ALTERNATE)) {
-   crop->height = infmt->height;
-   crop->top = (infmt->height == 480) ? 2 : 0;
+   crop->height = in_height;
+   crop->top = (in_height == 480) ? 2 : 0;
} else {
-   crop->height = min_t(__u32, infmt->height, crop->height);
-   if (crop->top + crop->height > infmt->height)
-   crop->top = infmt->height - crop->height;
+   crop->height = min_t(__u32, in_height, crop->height);
+   if (crop->top + crop->height > in_height)
+   crop->top = in_height - crop->height;
}
 }
 
@@ -1403,6 +1409,8 @@ static void csi_try_fmt(struct csi_priv *priv,
crop->top = 0;
crop->width = sdformat->format.width;
crop->height = sdformat->format.height;
+   if (sdformat->format.field == V4L2_FIELD_ALTERNATE)
+   crop->height *= 2;
csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep);
compose->left = 0;
compose->top = 0;
@@ -1530,6 +1538,8 @@ static int csi_get_selection(struct v4l2_subdev *sd,
sel->r.top = 0;
sel->r.width = infmt->width;
sel->r.height = infmt->height;
+   if (infmt->field == V4L2_FIELD_ALTERNATE)
+   sel->r.height *= 2;
break;
case V4L2_SEL_TGT_CROP:
sel->r = *crop;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 02/11] gpu: ipu-csi: Swap fields according to input/output field types

2019-01-09 Thread Steve Longerbeam
The function ipu_csi_init_interface() was inverting the F-bit for
NTSC case, in the CCIR_CODE_1/2 registers. The result being that
for NTSC bottom-top field order, the CSI would swap fields and
capture in top-bottom order.

Instead, base field swap on the field order of the input to the CSI,
and the field order of the requested output. If the input/output
fields are sequential but different, swap fields, otherwise do
not swap. This requires passing both the input and output mbus
frame formats to ipu_csi_init_interface().

Move this code to a new private function ipu_csi_set_bt_interlaced_codes()
that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and
possibly interlaced BT.1120 in the future).

When detecting input video standard from the input frame width/height,
make sure to double height if input field type is alternate, since
in that case input height only includes lines for one field.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
Changes since v5:
- Convert to const the infmt, outfmt, and mbus_cfg pointer args to
  ipu_csi_init_interface(), suggested by Philipp Zabel.
- Bring back if_fmt local var and don't copy outfmt to local stack in
  csi_setup(), suggested by Philipp.

Changes since v4:
- Cleaned up some convoluted code in ipu_csi_init_interface(), suggested
  by Philipp.
- Fixed a regression in csi_setup(), caught by Philipp.
---
 drivers/gpu/ipu-v3/ipu-csi.c  | 126 +++---
 drivers/staging/media/imx/imx-media-csi.c |   7 +-
 include/video/imx-ipu-v3.h|   5 +-
 3 files changed, 89 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index aa0e30a2ba18..d1e575571a8d 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -325,12 +325,21 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config 
*cfg, u32 mbus_code,
return 0;
 }
 
+/* translate alternate field mode based on given standard */
+static inline enum v4l2_field
+ipu_csi_translate_field(enum v4l2_field field, v4l2_std_id std)
+{
+   return (field != V4L2_FIELD_ALTERNATE) ? field :
+   ((std & V4L2_STD_525_60) ?
+V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB);
+}
+
 /*
  * Fill a CSI bus config struct from mbus_config and mbus_framefmt.
  */
 static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
-struct v4l2_mbus_config *mbus_cfg,
-struct v4l2_mbus_framefmt *mbus_fmt)
+   const struct v4l2_mbus_config *mbus_cfg,
+   const struct v4l2_mbus_framefmt *mbus_fmt)
 {
int ret;
 
@@ -374,22 +383,76 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config 
*csicfg,
return 0;
 }
 
+static int
+ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi,
+   const struct v4l2_mbus_framefmt *infmt,
+   const struct v4l2_mbus_framefmt *outfmt,
+   v4l2_std_id std)
+{
+   enum v4l2_field infield, outfield;
+   bool swap_fields;
+
+   /* get translated field type of input and output */
+   infield = ipu_csi_translate_field(infmt->field, std);
+   outfield = ipu_csi_translate_field(outfmt->field, std);
+
+   /*
+* Write the H-V-F codes the CSI will match against the
+* incoming data for start/end of active and blanking
+* field intervals. If input and output field types are
+* sequential but not the same (one is SEQ_BT and the other
+* is SEQ_TB), swap the F-bit so that the CSI will capture
+* field 1 lines before field 0 lines.
+*/
+   swap_fields = (V4L2_FIELD_IS_SEQUENTIAL(infield) &&
+  V4L2_FIELD_IS_SEQUENTIAL(outfield) &&
+  infield != outfield);
+
+   if (!swap_fields) {
+   /*
+* Field0BlankEnd  = 110, Field0BlankStart  = 010
+* Field0ActiveEnd = 100, Field0ActiveStart = 000
+* Field1BlankEnd  = 111, Field1BlankStart  = 011
+* Field1ActiveEnd = 101, Field1ActiveStart = 001
+*/
+   ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+   ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
+   } else {
+   dev_dbg(csi->ipu->dev, "capture field swap\n");
+
+   /* same as above but with F-bit inverted */
+   ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN,
+ CSI_CCIR_CODE_1);
+   ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2);
+   }
+
+   ipu_csi_write(csi, 0xFF, CSI_CCIR_CODE_3);
+
+   return 0;
+}
+
+
 int ipu_csi_init_interface(struct ipu_csi *csi,
-  struct v4l2_mbus_config *mbus_cfg,
-  struct v4l2_mbus_framefmt *mbus_fmt)
+   

[PATCH v7 07/11] media: imx-csi: Allow skipping odd chroma rows for YVU420

2019-01-09 Thread Steve Longerbeam
Skip writing U/V components to odd rows for YVU420 in addition to
YUV420 and NV12.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-media-csi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 604d0bd24389..6f1e11b8a7cb 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -452,6 +452,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
passthrough_bits = 16;
break;
case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_NV12:
burst_size = (image.pix.width & 0x3f) ?
 ((image.pix.width & 0x1f) ?
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 03/11] gpu: ipu-v3: Add planar support to interlaced scan

2019-01-09 Thread Steve Longerbeam
To support interlaced scan with planar formats, cpmem SLUV must
be programmed with the correct chroma line stride. For full and
partial planar 4:2:2 (YUV422P, NV16), chroma line stride must
be doubled. For full and partial planar 4:2:0 (YUV420, YVU420, NV12),
chroma line stride must _not_ be doubled, since a single chroma line
is shared by two luma lines.

Signed-off-by: Steve Longerbeam 
Reviewed-by: Philipp Zabel 
Acked-by: Philipp Zabel 
---
 drivers/gpu/ipu-v3/ipu-cpmem.c  | 26 +++--
 drivers/staging/media/imx/imx-ic-prpencvf.c |  3 ++-
 drivers/staging/media/imx/imx-media-csi.c   |  3 ++-
 include/video/imx-ipu-v3.h  |  3 ++-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index 163fadb8a33a..d047a6867c59 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -277,9 +277,10 @@ void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 
u_off, u32 v_off)
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset);
 
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+  u32 pixelformat)
 {
-   u32 ilo, sly;
+   u32 ilo, sly, sluv;
 
if (stride < 0) {
stride = -stride;
@@ -290,9 +291,30 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, 
int stride)
 
sly = (stride * 2) - 1;
 
+   switch (pixelformat) {
+   case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
+   sluv = stride / 2 - 1;
+   break;
+   case V4L2_PIX_FMT_NV12:
+   sluv = stride - 1;
+   break;
+   case V4L2_PIX_FMT_YUV422P:
+   sluv = stride - 1;
+   break;
+   case V4L2_PIX_FMT_NV16:
+   sluv = stride * 2 - 1;
+   break;
+   default:
+   sluv = 0;
+   break;
+   }
+
ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1);
ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo);
ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly);
+   if (sluv)
+   ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, sluv);
 };
 EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
 
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 28f41caba05d..af7224846bd5 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -412,7 +412,8 @@ static int prp_setup_channel(struct prp_priv *priv,
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field) &&
channel == priv->out_ch)
-   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline);
+   ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline,
+ image.pix.pixelformat);
 
ret = ipu_ic_task_idma_init(priv->ic, channel,
image.pix.width, image.pix.height,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index c2a8d9cd31b7..da4808348845 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -512,7 +512,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
if (image.pix.field == V4L2_FIELD_NONE &&
V4L2_FIELD_HAS_BOTH(infmt->field))
ipu_cpmem_interlaced_scan(priv->idmac_ch,
- image.pix.bytesperline);
+ image.pix.bytesperline,
+ image.pix.pixelformat);
 
ipu_idmac_set_double_buffer(priv->idmac_ch, true);
 
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index bbc8481f567d..c887f4bee5f8 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -258,7 +258,8 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int 
stride);
 void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
 void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t 
buf);
 void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off);
-void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
+void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride,
+  u32 pixelformat);
 void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id);
 int ipu_cpmem_get_burstsize(struct ipuv3_channel *ch);
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 05/12] media: imx-csi: Input connections to CSI should be optional

2019-01-09 Thread Steve Longerbeam




On 1/9/19 3:13 AM, Philipp Zabel wrote:

On Tue, 2019-01-08 at 16:15 -0800, Steve Longerbeam wrote:

Some imx platforms do not have fwnode connections to all CSI input
ports, and should not be treated as an error. This includes the
imx6q SabreAuto, which has no connections to ipu1_csi1 and ipu2_csi0.
Return -ENOTCONN in imx_csi_parse_endpoint() so that v4l2-fwnode
endpoint parsing will not treat an unconnected endpoint as an error.

Fixes: c893500a16baf ("media: imx: csi: Register a subdev notifier")

Signed-off-by: Steve Longerbeam 
---
  drivers/staging/media/imx/imx-media-csi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index e3a4f39dbf73..b276672cae1d 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1815,7 +1815,7 @@ static int imx_csi_parse_endpoint(struct device *dev,
  struct v4l2_fwnode_endpoint *vep,
  struct v4l2_async_subdev *asd)
  {
-   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
+   return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
  }
  
  static int imx_csi_async_register(struct csi_priv *priv)

Is this something that should be applied as a fix, separately from this
series?


Yes. I'll submit it separately and send a v7 of this series without it.

Steve


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] media: cedrus: Allow using the current dst buffer as reference

2019-01-09 Thread Hans Verkuil
On 01/09/19 15:42, Paul Kocialkowski wrote:
> Hi,
> 
> On Wed, 2019-01-09 at 15:29 +0100, Hans Verkuil wrote:
>> On 01/09/19 15:19, Paul Kocialkowski wrote:
>>> It was reported that some cases of interleaved video decoding require
>>> using the current destination buffer as a reference. However, this is
>>> no longer possible after the move to vb2_find_timestamp because only
>>> dequeued and done buffers are considered.
>>>
>>> Add a helper in our driver that also considers the current destination
>>> buffer before resorting to vb2_find_timestamp and use it in MPEG-2.
>>
>> This patch looks good, but can you also add checks to handle the case
>> when no buffer with the given timestamp was found? Probably should be done
>> in a third patch.
>>
>> I suspect the driver will crash if an unknown timestamp is passed on to the
>> driver. I would really like to see that corner case fixed.
> 
> You're totally right and I think that more generarlly, the current code
> flow is rather fragile whenever something wrong happens in our setup()
> codec op. I think we should at least have that op return an error code
> and properly deal with it when that occurs.
> 
> I am planning on making a cleanup series to fix that.
> 
> Before using timestamps, reference buffer index validation was done in
> std_validate and now it's fully up to the driver. I wonder if it would
> be feasible to bring something back in there since all stateless
> drivers will face the same issue. The conditions set in
> cedrus_reference_index_find seem generic enough for that, but we should
> check that std_validate is not called too early, when the queue is in a
> different state (and the buffer might not be dequeud or done yet).
> 
> What do you think?

I don't think you can do that. Say you queue a buffer that refers to a
ref frame F, and F is a buffer that's been dequeued. When std_validate is
called, this is fine and valid. Now later (but before the request is
processed) buffer F is queued by the application. Now F is no longer valid.

So when the driver processes the request, it won't be able to find F anymore.

A more interesting question is what you should do if a reference frame isn't
found. And should that be documented in the stateless decoder spec? (Or perhaps
it's there already, I'm not sure).

Regards,

Hans

> 
> Cheers,
> 
> Paul
> 
>>> Signed-off-by: Paul Kocialkowski 
>>> ---
>>>  drivers/staging/media/sunxi/cedrus/cedrus_dec.c   | 13 +
>>>  drivers/staging/media/sunxi/cedrus/cedrus_dec.h   |  2 ++
>>>  drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 10 ++
>>>  3 files changed, 21 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c 
>>> b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
>>> index 443fb037e1cf..2c295286766c 100644
>>> --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
>>> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
>>> @@ -22,6 +22,19 @@
>>>  #include "cedrus_dec.h"
>>>  #include "cedrus_hw.h"
>>>  
>>> +int cedrus_reference_index_find(struct vb2_queue *queue,
>>> +   struct vb2_buffer *vb2_buf, u64 timestamp)
>>> +{
>>> +   /*
>>> +* Allow using the current capture buffer as reference, which can occur
>>> +* for field-coded pictures.
>>> +*/
>>> +   if (vb2_buf->timestamp == timestamp)
>>> +   return vb2_buf->index;
>>> +   else
>>> +   return vb2_find_timestamp(queue, timestamp, 0);
>>> +}
>>> +
>>>  void cedrus_device_run(void *priv)
>>>  {
>>> struct cedrus_ctx *ctx = priv;
>>> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
>>> b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
>>> index d1ae7903677b..8d0fc248220f 100644
>>> --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
>>> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
>>> @@ -16,6 +16,8 @@
>>>  #ifndef _CEDRUS_DEC_H_
>>>  #define _CEDRUS_DEC_H_
>>>  
>>> +int cedrus_reference_index_find(struct vb2_queue *queue,
>>> +   struct vb2_buffer *vb2_buf, u64 timestamp);
>>>  void cedrus_device_run(void *priv);
>>>  
>>>  #endif
>>> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c 
>>> b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
>>> index cb45fda9aaeb..81c66a8aa1ac 100644
>>> --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
>>> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
>>> @@ -10,6 +10,7 @@
>>>  #include 
>>>  
>>>  #include "cedrus.h"
>>> +#include "cedrus_dec.h"
>>>  #include "cedrus_hw.h"
>>>  #include "cedrus_regs.h"
>>>  
>>> @@ -159,8 +160,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
>>> struct cedrus_run *run)
>>> cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
>>>  
>>> /* Forward and backward prediction reference buffers. */
>>> -   forward_idx = vb2_find_timestamp(cap_q,
>>> -slice_params->forward_ref_ts, 0);
>>> +   forward_idx = cedrus_reference_index_find(cap_q

[PATCH] staging/android/vsoc: Remove duplicate header

2019-01-09 Thread Brajeswar Ghosh
Remove linux/mutex.h.h which is included more than once

Signed-off-by: Brajeswar Ghosh 
---
 drivers/staging/android/vsoc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
index 22571abcaa4e..8a75bd27c413 100644
--- a/drivers/staging/android/vsoc.c
+++ b/drivers/staging/android/vsoc.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "uapi/vsoc_shm.h"
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] media: cedrus: Allow using the current dst buffer as reference

2019-01-09 Thread Paul Kocialkowski
Hi,

On Wed, 2019-01-09 at 15:29 +0100, Hans Verkuil wrote:
> On 01/09/19 15:19, Paul Kocialkowski wrote:
> > It was reported that some cases of interleaved video decoding require
> > using the current destination buffer as a reference. However, this is
> > no longer possible after the move to vb2_find_timestamp because only
> > dequeued and done buffers are considered.
> > 
> > Add a helper in our driver that also considers the current destination
> > buffer before resorting to vb2_find_timestamp and use it in MPEG-2.
> 
> This patch looks good, but can you also add checks to handle the case
> when no buffer with the given timestamp was found? Probably should be done
> in a third patch.
> 
> I suspect the driver will crash if an unknown timestamp is passed on to the
> driver. I would really like to see that corner case fixed.

You're totally right and I think that more generarlly, the current code
flow is rather fragile whenever something wrong happens in our setup()
codec op. I think we should at least have that op return an error code
and properly deal with it when that occurs.

I am planning on making a cleanup series to fix that.

Before using timestamps, reference buffer index validation was done in
std_validate and now it's fully up to the driver. I wonder if it would
be feasible to bring something back in there since all stateless
drivers will face the same issue. The conditions set in
cedrus_reference_index_find seem generic enough for that, but we should
check that std_validate is not called too early, when the queue is in a
different state (and the buffer might not be dequeud or done yet).

What do you think?

Cheers,

Paul

> > Signed-off-by: Paul Kocialkowski 
> > ---
> >  drivers/staging/media/sunxi/cedrus/cedrus_dec.c   | 13 +
> >  drivers/staging/media/sunxi/cedrus/cedrus_dec.h   |  2 ++
> >  drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 10 ++
> >  3 files changed, 21 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c 
> > b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> > index 443fb037e1cf..2c295286766c 100644
> > --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> > @@ -22,6 +22,19 @@
> >  #include "cedrus_dec.h"
> >  #include "cedrus_hw.h"
> >  
> > +int cedrus_reference_index_find(struct vb2_queue *queue,
> > +   struct vb2_buffer *vb2_buf, u64 timestamp)
> > +{
> > +   /*
> > +* Allow using the current capture buffer as reference, which can occur
> > +* for field-coded pictures.
> > +*/
> > +   if (vb2_buf->timestamp == timestamp)
> > +   return vb2_buf->index;
> > +   else
> > +   return vb2_find_timestamp(queue, timestamp, 0);
> > +}
> > +
> >  void cedrus_device_run(void *priv)
> >  {
> > struct cedrus_ctx *ctx = priv;
> > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
> > b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> > index d1ae7903677b..8d0fc248220f 100644
> > --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> > @@ -16,6 +16,8 @@
> >  #ifndef _CEDRUS_DEC_H_
> >  #define _CEDRUS_DEC_H_
> >  
> > +int cedrus_reference_index_find(struct vb2_queue *queue,
> > +   struct vb2_buffer *vb2_buf, u64 timestamp);
> >  void cedrus_device_run(void *priv);
> >  
> >  #endif
> > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c 
> > b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > index cb45fda9aaeb..81c66a8aa1ac 100644
> > --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > @@ -10,6 +10,7 @@
> >  #include 
> >  
> >  #include "cedrus.h"
> > +#include "cedrus_dec.h"
> >  #include "cedrus_hw.h"
> >  #include "cedrus_regs.h"
> >  
> > @@ -159,8 +160,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
> > struct cedrus_run *run)
> > cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
> >  
> > /* Forward and backward prediction reference buffers. */
> > -   forward_idx = vb2_find_timestamp(cap_q,
> > -slice_params->forward_ref_ts, 0);
> > +   forward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
> > + slice_params->forward_ref_ts);
> >  
> > fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
> > fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
> > @@ -168,8 +169,9 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
> > struct cedrus_run *run)
> > cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr);
> > cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr);
> >  
> > -   backward_idx = vb2_find_timestamp(cap_q,
> > - slice_params->backward_ref_ts, 0);
> > +   backward_idx = cedrus_reference_index_find(ca

Re: [PATCH 2/2] media: cedrus: Allow using the current dst buffer as reference

2019-01-09 Thread Hans Verkuil
On 01/09/19 15:19, Paul Kocialkowski wrote:
> It was reported that some cases of interleaved video decoding require
> using the current destination buffer as a reference. However, this is
> no longer possible after the move to vb2_find_timestamp because only
> dequeued and done buffers are considered.
> 
> Add a helper in our driver that also considers the current destination
> buffer before resorting to vb2_find_timestamp and use it in MPEG-2.

This patch looks good, but can you also add checks to handle the case
when no buffer with the given timestamp was found? Probably should be done
in a third patch.

I suspect the driver will crash if an unknown timestamp is passed on to the
driver. I would really like to see that corner case fixed.

Regards,

Hans

> 
> Signed-off-by: Paul Kocialkowski 
> ---
>  drivers/staging/media/sunxi/cedrus/cedrus_dec.c   | 13 +
>  drivers/staging/media/sunxi/cedrus/cedrus_dec.h   |  2 ++
>  drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 10 ++
>  3 files changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c 
> b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> index 443fb037e1cf..2c295286766c 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> @@ -22,6 +22,19 @@
>  #include "cedrus_dec.h"
>  #include "cedrus_hw.h"
>  
> +int cedrus_reference_index_find(struct vb2_queue *queue,
> + struct vb2_buffer *vb2_buf, u64 timestamp)
> +{
> + /*
> +  * Allow using the current capture buffer as reference, which can occur
> +  * for field-coded pictures.
> +  */
> + if (vb2_buf->timestamp == timestamp)
> + return vb2_buf->index;
> + else
> + return vb2_find_timestamp(queue, timestamp, 0);
> +}
> +
>  void cedrus_device_run(void *priv)
>  {
>   struct cedrus_ctx *ctx = priv;
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
> b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> index d1ae7903677b..8d0fc248220f 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
> @@ -16,6 +16,8 @@
>  #ifndef _CEDRUS_DEC_H_
>  #define _CEDRUS_DEC_H_
>  
> +int cedrus_reference_index_find(struct vb2_queue *queue,
> + struct vb2_buffer *vb2_buf, u64 timestamp);
>  void cedrus_device_run(void *priv);
>  
>  #endif
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c 
> b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> index cb45fda9aaeb..81c66a8aa1ac 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> @@ -10,6 +10,7 @@
>  #include 
>  
>  #include "cedrus.h"
> +#include "cedrus_dec.h"
>  #include "cedrus_hw.h"
>  #include "cedrus_regs.h"
>  
> @@ -159,8 +160,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
> struct cedrus_run *run)
>   cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
>  
>   /* Forward and backward prediction reference buffers. */
> - forward_idx = vb2_find_timestamp(cap_q,
> -  slice_params->forward_ref_ts, 0);
> + forward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
> +   slice_params->forward_ref_ts);
>  
>   fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
>   fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
> @@ -168,8 +169,9 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
> struct cedrus_run *run)
>   cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr);
>   cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr);
>  
> - backward_idx = vb2_find_timestamp(cap_q,
> -   slice_params->backward_ref_ts, 0);
> + backward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
> +
> slice_params->backward_ref_ts);
> +
>   bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0);
>   bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1);
>  
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] media: cedrus: Allow using the current dst buffer as reference

2019-01-09 Thread Paul Kocialkowski
It was reported that some cases of interleaved video decoding require
using the current destination buffer as a reference. However, this is
no longer possible after the move to vb2_find_timestamp because only
dequeued and done buffers are considered.

Add a helper in our driver that also considers the current destination
buffer before resorting to vb2_find_timestamp and use it in MPEG-2.

Signed-off-by: Paul Kocialkowski 
---
 drivers/staging/media/sunxi/cedrus/cedrus_dec.c   | 13 +
 drivers/staging/media/sunxi/cedrus/cedrus_dec.h   |  2 ++
 drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 10 ++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c 
b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
index 443fb037e1cf..2c295286766c 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
@@ -22,6 +22,19 @@
 #include "cedrus_dec.h"
 #include "cedrus_hw.h"
 
+int cedrus_reference_index_find(struct vb2_queue *queue,
+   struct vb2_buffer *vb2_buf, u64 timestamp)
+{
+   /*
+* Allow using the current capture buffer as reference, which can occur
+* for field-coded pictures.
+*/
+   if (vb2_buf->timestamp == timestamp)
+   return vb2_buf->index;
+   else
+   return vb2_find_timestamp(queue, timestamp, 0);
+}
+
 void cedrus_device_run(void *priv)
 {
struct cedrus_ctx *ctx = priv;
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
index d1ae7903677b..8d0fc248220f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
@@ -16,6 +16,8 @@
 #ifndef _CEDRUS_DEC_H_
 #define _CEDRUS_DEC_H_
 
+int cedrus_reference_index_find(struct vb2_queue *queue,
+   struct vb2_buffer *vb2_buf, u64 timestamp);
 void cedrus_device_run(void *priv);
 
 #endif
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c 
b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
index cb45fda9aaeb..81c66a8aa1ac 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
@@ -10,6 +10,7 @@
 #include 
 
 #include "cedrus.h"
+#include "cedrus_dec.h"
 #include "cedrus_hw.h"
 #include "cedrus_regs.h"
 
@@ -159,8 +160,8 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
struct cedrus_run *run)
cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
 
/* Forward and backward prediction reference buffers. */
-   forward_idx = vb2_find_timestamp(cap_q,
-slice_params->forward_ref_ts, 0);
+   forward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
+ slice_params->forward_ref_ts);
 
fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
@@ -168,8 +169,9 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
struct cedrus_run *run)
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr);
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr);
 
-   backward_idx = vb2_find_timestamp(cap_q,
- slice_params->backward_ref_ts, 0);
+   backward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf,
+  
slice_params->backward_ref_ts);
+
bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0);
bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1);
 
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] media: cedrus: Cleanup duplicate declarations from cedrus_dec header

2019-01-09 Thread Paul Kocialkowski
Some leftover declarations are still in the cedrus_dec header although
they were moved to cedrus_video already. Clean them up.

Signed-off-by: Paul Kocialkowski 
---
 drivers/staging/media/sunxi/cedrus/cedrus_dec.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
index 4f423d3a1cad..d1ae7903677b 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
@@ -16,12 +16,6 @@
 #ifndef _CEDRUS_DEC_H_
 #define _CEDRUS_DEC_H_
 
-extern const struct v4l2_ioctl_ops cedrus_ioctl_ops;
-
-void cedrus_device_work(struct work_struct *work);
 void cedrus_device_run(void *priv);
 
-int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
- struct vb2_queue *dst_vq);
-
 #endif
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH -next] staging: wilc1000: remove set but not used variable 'msa'

2019-01-09 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/staging/wilc1000/host_interface.c: In function 
'wilc_parse_network_info':
drivers/staging/wilc1000/host_interface.c:748:16: warning:
 variable 'msa' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 5dae6e7..c05c120 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -745,7 +745,7 @@ static s32 wilc_parse_network_info(u8 *msg_buffer,
 {
struct network_info *info;
struct ieee80211_mgmt *mgt;
-   u8 *wid_val, *msa, *ies;
+   u8 *wid_val, *ies;
u16 wid_len, rx_len, ies_len;
u8 msg_type;
size_t offset;
@@ -764,7 +764,6 @@ static s32 wilc_parse_network_info(u8 *msg_buffer,
 
info->rssi = wid_val[0];
 
-   msa = &wid_val[1];
mgt = (struct ieee80211_mgmt *)&wid_val[1];
rx_len = wid_len - 1;
 





___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Nicolas Saenz Julienne
Hi Stefan,

On Wed, 2019-01-09 at 09:33 +0100, Stefan Wahren wrote:
> 
> But i noticed a regression introduced in 5.0-rc1, which might be
> related. I
> tried to run "vchiq_test -f 1" and it never completes. After
> reverting commit
> 852b2876a8a8 ("staging: vchiq: rework remove_event handling")
> vchiq_test [1]
> works as expected again.

I had a look at that one, it seems that it's due to the fact that vchiq
relies on completions only sleeping whenever their internal count
reaches 0 (it's incremented on every complete()). As opposed to
wait_queues, which will wait until an event is triggered regardless of
previous state.

Regards,
Nicolas


signature.asc
Description: This is a digitally signed message part
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 4/4] staging: greybus: arche-platform: Switch to the gpio descriptor interface

2019-01-09 Thread Johan Hovold
On Sat, Dec 22, 2018 at 08:23:02PM +0530, Nishad Kamdar wrote:
> Use the gpiod interface instead of the deprecated
> old non-descriptor interface.
> 
> Signed-off-by: Nishad Kamdar 
> ---
> Changes in v4:
>  - Move 'gpio_desc *svc_sysboot' below the reset flag
>as it is more logical to have reset flag below
>reset gpio.
>  - Remove a few unnecessary line breaks.
> Changes in v3:
>  - Add this patch to a patchset.
> Changes in v2:
>  - Move comment to the same line as to what it applies to.
> ---

> -static inline void svc_reset_onoff(unsigned int gpio, bool onoff)
> +static inline void svc_reset_onoff(struct gpio_desc *gpio, bool onoff)
>  {
> - gpio_set_value(gpio, onoff);
> + gpiod_set_value(gpio, onoff);
>  }

Please use the raw interface here too, until we've done away with the
polarity properties and can honour the generic device tree flags. Please
make a comment about this in the commit message too.

> @@ -444,61 +438,33 @@ static int arche_platform_probe(struct platform_device 
> *pdev)
>   /* setup svc reset gpio */
>   arche_pdata->is_reset_act_hi = of_property_read_bool(np,
>
> "svc,reset-active-high");
> - arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
> - "svc,reset-gpio",
> - 0);
> - if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
> - dev_err(dev, "failed to get reset-gpio\n");
> - return arche_pdata->svc_reset_gpio;
> - }
> - ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, "svc-reset");
> - if (ret) {
> - dev_err(dev, "failed to request svc-reset gpio:%d\n", ret);
> - return ret;
> - }
> - ret = gpio_direction_output(arche_pdata->svc_reset_gpio,
> - arche_pdata->is_reset_act_hi);
> - if (ret) {
> - dev_err(dev, "failed to set svc-reset gpio dir:%d\n", ret);
> + if (arche_pdata->is_reset_act_hi)
> + flags = GPIOD_OUT_HIGH;
> + else
> + flags = GPIOD_OUT_LOW;
> +
> + arche_pdata->svc_reset = devm_gpiod_get(dev, "svc,reset-gpio", flags);

Again, you cannot just rename devicetree properties like this. Keep the
current names for now (and drop the -gpio suffix when requesting).

Johan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 3/4] staging: greybus: arche-apb-ctrl.c: Switch to the gpio descriptor interface

2019-01-09 Thread Johan Hovold
On Sat, Dec 22, 2018 at 08:22:09PM +0530, Nishad Kamdar wrote:
> Use the gpiod interface instead of the deprecated old non-descriptor
> interface.
> 
> Signed-off-by: Nishad Kamdar 
> ---
> Changes in v4:
>  - Use gpiod_set_raw_value() for deassert_reset() and
>assert_reset() as gpiod_set_value() will change the
>sematics of these calls by taking any gpio flags
>into account.

Please also mention this in the commit message (i.e. that we continue to
ignore gpio flags from device tree for now).

>  - Remove some unnecesssary line breaks.
>  - Restore 'spi_en' gpio check in fw_flashing_seq()
>as it is currently optional.
> Changes in v3:
>  - Add this patch in a patchset.
> Changes in v2:
>  - Resolved compilation errors.
> ---

> @@ -75,11 +74,10 @@ static int coldboot_seq(struct platform_device *pdev)
>   return 0;
>  
>   /* Hold APB in reset state */
> - assert_reset(apb->resetn_gpio);
> + assert_reset(apb->resetn);
>  
> - if (apb->state == ARCHE_PLATFORM_STATE_FW_FLASHING &&
> - gpio_is_valid(apb->spi_en_gpio))
> - devm_gpio_free(dev, apb->spi_en_gpio);
> + if (apb->state == ARCHE_PLATFORM_STATE_FW_FLASHING && apb->spi_en)
> + devm_gpiod_put(dev, apb->spi_en);
>  
>   /* Enable power to APB */
>   if (!IS_ERR(apb->vcore)) {
> @@ -101,13 +99,13 @@ static int coldboot_seq(struct platform_device *pdev)
>   apb_bootret_deassert(dev);
>  
>   /* On DB3 clock was not mandatory */
> - if (gpio_is_valid(apb->clk_en_gpio))
> - gpio_set_value(apb->clk_en_gpio, 1);
> + if (apb->clk_en)
> + gpiod_set_value(apb->clk_en, 1);
>  
>   usleep_range(100, 200);
>  
>   /* deassert reset to APB : Active-low signal */
> - deassert_reset(apb->resetn_gpio);
> + deassert_reset(apb->resetn);
>  
>   apb->state = ARCHE_PLATFORM_STATE_ACTIVE;
>  
> @@ -136,25 +134,25 @@ static int fw_flashing_seq(struct platform_device *pdev)
>   return ret;
>   }
>  
> - if (gpio_is_valid(apb->spi_en_gpio)) {
> + if (apb->spi_en) {
>   unsigned long flags;
>  
>   if (apb->spi_en_polarity_high)
> - flags = GPIOF_OUT_INIT_HIGH;
> + flags = GPIOD_OUT_HIGH;
>   else
> - flags = GPIOF_OUT_INIT_LOW;
> + flags = GPIOD_OUT_LOW;
>  
> - ret = devm_gpio_request_one(dev, apb->spi_en_gpio,
> - flags, "apb_spi_en");
> - if (ret) {
> - dev_err(dev, "Failed requesting SPI bus en gpio %d\n",
> - apb->spi_en_gpio);
> + apb->spi_en = devm_gpiod_get(dev, "gb,spi-en-gpio", flags);

I just noticed that you change the name of the device-tree property here
(and later in apb_ctrl_get_devtree_data()). How is that expected to
work without breaking current systems? This will be unavoidable at some
point, but must not be snuck into a patch like this without any comment.
Please keep the current names for now.

I do think you need to drop the "-gpio" suffix when requesting the gpio
though. Please double check to make sure.

Johan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 05/12] media: imx-csi: Input connections to CSI should be optional

2019-01-09 Thread Philipp Zabel
On Tue, 2019-01-08 at 16:15 -0800, Steve Longerbeam wrote:
> Some imx platforms do not have fwnode connections to all CSI input
> ports, and should not be treated as an error. This includes the
> imx6q SabreAuto, which has no connections to ipu1_csi1 and ipu2_csi0.
> Return -ENOTCONN in imx_csi_parse_endpoint() so that v4l2-fwnode
> endpoint parsing will not treat an unconnected endpoint as an error.
> 
> Fixes: c893500a16baf ("media: imx: csi: Register a subdev notifier")
> 
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/staging/media/imx/imx-media-csi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> b/drivers/staging/media/imx/imx-media-csi.c
> index e3a4f39dbf73..b276672cae1d 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -1815,7 +1815,7 @@ static int imx_csi_parse_endpoint(struct device *dev,
> struct v4l2_fwnode_endpoint *vep,
> struct v4l2_async_subdev *asd)
>  {
> - return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
> + return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
>  }
>  
>  static int imx_csi_async_register(struct csi_priv *priv)

Is this something that should be applied as a fix, separately from this
series?

regards
Philipp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6 02/12] gpu: ipu-csi: Swap fields according to input/output field types

2019-01-09 Thread Philipp Zabel
On Tue, 2019-01-08 at 16:15 -0800, Steve Longerbeam wrote:
> The function ipu_csi_init_interface() was inverting the F-bit for
> NTSC case, in the CCIR_CODE_1/2 registers. The result being that
> for NTSC bottom-top field order, the CSI would swap fields and
> capture in top-bottom order.
> 
> Instead, base field swap on the field order of the input to the CSI,
> and the field order of the requested output. If the input/output
> fields are sequential but different, swap fields, otherwise do
> not swap. This requires passing both the input and output mbus
> frame formats to ipu_csi_init_interface().
> 
> Move this code to a new private function ipu_csi_set_bt_interlaced_codes()
> that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and
> possibly interlaced BT.1120 in the future).
> 
> When detecting input video standard from the input frame width/height,
> make sure to double height if input field type is alternate, since
> in that case input height only includes lines for one field.
> 
> Signed-off-by: Steve Longerbeam 
> Reviewed-by: Philipp Zabel 

Also
Acked-by: Philipp Zabel 
to be merged via the media tree

regards
Philipp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 2/4] staging: greybus: gpio: Use gpiochip_get_data() in place of gpio_chip_to_gb_gpio_controller()

2019-01-09 Thread Johan Hovold
On Sat, Dec 22, 2018 at 08:21:00PM +0530, Nishad Kamdar wrote:
> This patch drops gpio_chip_to_gb_gpio_controller(),
> and uses gpiochip_get_data() to retrieve the container
> of struct gpio_chip.

So this will break the driver, since gpiochip_add() sets the data
pointer to NULL.

These kind of changes are getting too complicated to do without
something to test against. We had a module simulator at one point, but
not sure what the state of that is now.

I appreciate the effort though, and since we already started, let's try
to finish, but please drop this patch for now.

Johan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 1/4] staging: greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP

2019-01-09 Thread Johan Hovold
On Sat, Dec 22, 2018 at 08:17:02PM +0530, Nishad Kamdar wrote:
> Convert the GPIO driver to use the GPIO irqchip library
> GPIOLIB_IRQCHIP instead of reimplementing the same.
> 
> Signed-off-by: Nishad Kamdar 
> ---
> Changes in v4:
>  - Remove changes related to conversion to gpiochip_get_data() to
>include it as a new patch.
>  - Remove the 'struct irq_chip' field from 'struct gb_gpio_controller'
>as struct gpio_chip will have an irqchip whenever
>CONFIG_GPIOLIB_IRQCHIP is selected.

Ok, sorry for misleading you this. It seems we cannot use the gpio-chip
irqchip, since that will register the irqchip automatically and possibly
in an incompatible way. This new functionality is far from well
documented, and you basically have to review the gpiolib code to figure
it out.

Looks like you need to add back the struct irq_chip.

Johan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH AUTOSEL 4.20 056/117] media: cedrus: don't initialize pointers with zero

2019-01-09 Thread Dan Carpenter
This is a pure cleanup patch, it doesn't affect runtime.

On Tue, Jan 08, 2019 at 02:25:24PM -0500, Sasha Levin wrote:
> From: Mauro Carvalho Chehab 
> 
> [ Upstream commit e4d7b113fdccde1acf8638c5879f2a450d492303 ]
> 
> A common mistake is to assume that initializing a var with:
>   struct foo f = { 0 };
> 
> Would initialize a zeroed struct. Actually, what this does is
> to initialize the first element of the struct to zero.
> 
> According to C99 Standard 6.7.8.21:
> 
> "If there are fewer initializers in a brace-enclosed
>  list than there are elements or members of an aggregate,
>  or fewer characters in a string literal used to initialize
>  an array of known size than there are elements in the array,
>  the remainder of the aggregate shall be initialized implicitly
>  the same as objects that have static storage duration."

Static storage is initialized to zero so this is fine.  It's just
that Sparse complains if you mix NULL and zero.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC 00/11] staging: vc04_services: Improve driver load/unload

2019-01-09 Thread Stefan Wahren
Hi,

[add Arnd]

> Dave Stevenson  hat am 8. Januar 2019 um 18:10
> geschrieben:
> 
> 
> Hi Peter
> 
> On Tue, 8 Jan 2019 at 07:21, Peter Robinson  wrote:
> >
> > Hi Stefan,
> >
> > > This patch series improves the load/unload of bcm2835 camera and audio
> > > drivers. It has been tested with Raspberry Pi 3 B and a camera module V1.
> > >
> > > This series based on current linux-next and Phil Elwell's series ("Improve
> > > VCHIQ
> > > cache line size handling"). After Nicolas' series ("staging:
> > > vc04_services:
> > > Some dead code removal") has been applied, i will rebase my series.
> >
> > I tried testing this series applied to 4.20 with the camera module. I
> > tried with qv4l2 (from v4l-utils) and using cheese, which in turn uses
> > gstreamer. I basically get the same crash for both options. Desktop is
> > LXDE on 32 bit Fedora 29.
> >
> > I've not yet tried with 5.0-rc1 but it looks like it has this patch
> > series and some other bits for the vchiq drivers in staging.
> 
> I'm trying to sort the patches I have on our kernel tree and get them
> in a shape to get merged to staging.
> I've built for 5.0.0-rc1 and also see the same error using:
> v4l2-ctl -v width=640,height=480,pixelformat=YU12
> v4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=300
> 

i wasn't able to reproduce this issue yet (Raspberry Pi 3, Firmware:
2018-12-18 + 2018-11-12). qv4l2 and cheese from recent Raspbian shows an 
greenish image but
works.

I tried to capture a video with cheese but this seems to hang and after some
time i terminated cheese and got this kernel output:

[  238.330187] bcm2835_v4l2: timed out waiting for sync completion
[  238.330202] bcm2835-v4l2: Failed disabling camera, ret -62
[  238.330206] bcm2835-v4l2: Failed to disable camera
[  238.330211] [ cut here ]
[  238.330239] WARNING: CPU: 3 PID: 1259 at
drivers/media/common/videobuf2/videobuf2-core.c:1852
__vb2_queue_cancel+0x1d8/0x24c [videobuf2_common]
[  238.330242] Modules linked in: cmac bcm2835_v4l2(C) v4l2_common
videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev
media snd_bcm2835(C) brcmfmac sha256_generic sha256_arm vc4 snd_soc_core
ac97_bus snd_pcm_dmaengine snd_pcm snd_timer cfg80211 snd crc32_arm_ce
raspberrypi_hwmon soundcore brcmutil hci_uart btbcm bluetooth bcm2835_thermal
ecdh_generic vchiq(C) phy_generic microchip lan78xx
[  238.330328] CPU: 3 PID: 1259 Comm: v4l2src1:src Tainted: G C
   5.0.0-rc1-g3bd6e94be #2
[  238.330331] Hardware name: BCM2835
[  238.330359] [] (unwind_backtrace) from []
(show_stack+0x10/0x14)
[  238.330373] [] (show_stack) from []
(dump_stack+0x8c/0xa0)
[  238.330388] [] (dump_stack) from [] (__warn+0xe0/0xf8)
[  238.330401] [] (__warn) from []
(warn_slowpath_null+0x40/0x48)
[  238.330421] [] (warn_slowpath_null) from []
(__vb2_queue_cancel+0x1d8/0x24c [videobuf2_common])
[  238.330466] [] (__vb2_queue_cancel [videobuf2_common]) from
[] (vb2_core_queue_release+0x18/0x38 [videobuf2_common])
[  238.330490] [] (vb2_core_queue_release [videobuf2_common]) from
[] (_vb2_fop_release+0x74/0x84 [videobuf2_v4l2])
[  238.330533] [] (_vb2_fop_release [videobuf2_v4l2]) from
[] (v4l2_release+0x94/0xd8 [videodev])
[  238.330571] [] (v4l2_release [videodev]) from []
(__fput+0x84/0x1c8)
[  238.330588] [] (__fput) from [] (task_work_run+0xa8/0xcc)
[  238.330604] [] (task_work_run) from []
(do_exit+0x3a4/0xa90)
[  238.330618] [] (do_exit) from []
(do_group_exit+0x3c/0xd0)
[  238.330634] [] (do_group_exit) from []
(get_signal+0x24c/0x6d8)
[  238.330647] [] (get_signal) from []
(do_work_pending+0x150/0x5a8)
[  238.330659] [] (do_work_pending) from []
(slow_work_pending+0xc/0x20)
[  238.330665] Exception stack(0xe589ffb0 to 0xe589fff8)
[  238.330674] ffa0: ab203ea0 0002
 
[  238.330685] ffc0: 0008 0002 ab203ea0 0150  009bfd80
 
[  238.330695] ffe0: ab1fe54c ab1fe558  b6155d68 8010 ab203ea0
[  238.330701] ---[ end trace 38eb902c180397fe ]---
[  238.330710] videobuf2_common: driver bug: stop_streaming operation is leaving
buf a00b2206 in active state
[  238.330717] videobuf2_common: driver bug: stop_streaming operation is leaving
buf c6a3f306 in active state
[  238.330723] videobuf2_common: driver bug: stop_streaming operation is leaving
buf d3723ebf in active state
[  238.330728] videobuf2_common: driver bug: stop_streaming operation is leaving
buf fd514935 in active state

But i noticed a regression introduced in 5.0-rc1, which might be related. I
tried to run "vchiq_test -f 1" and it never completes. After reverting commit
852b2876a8a8 ("staging: vchiq: rework remove_event handling") vchiq_test [1]
works as expected again.

Regards
Stefan

[1] -
https://github.com/raspberrypi/userland/blob/master/interface/vchiq_arm/vchiq_test.c
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.o