[PATCH RFT/RFC v2 41/47] staging: media: zoran: add vidioc_g_parm

2020-09-25 Thread Corentin Labbe
Adding vidioc_g_parm made v4l compliance happy.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index bcbe2c78ea16..5dacbeac790b 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -2137,6 +2137,14 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
return res;
 }
 
+static int zoran_g_parm(struct file *file, void *priv, struct v4l2_streamparm 
*parm)
+{
+   if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
+   return 0;
+}
+
 /*
  * Output is disabled temporarily
  * Zoran is picky about jpeg data it accepts. At least it seems to unsupport 
COM and APPn.
@@ -2144,6 +2152,7 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
  */
 static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_querycap= zoran_querycap,
+   .vidioc_g_parm  = zoran_g_parm,
.vidioc_s_selection = zoran_s_selection,
.vidioc_g_selection = zoran_g_selection,
.vidioc_enum_input  = zoran_enum_input,
-- 
2.26.2

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


[PATCH RFT/RFC v2 25/47] staging: media: zoran: zoran does not support STD_ALL

2020-09-25 Thread Corentin Labbe
In fact, zoran does not support V4L2_STD_ALL, so let's enumerate what we
support.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 858e0910884c..60bbc8235cff 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1765,7 +1765,7 @@ static int zoran_enum_input(struct file *file, void *__fh,
 
strscpy(inp->name, zr->card.input[inp->index].name, sizeof(inp->name));
inp->type = V4L2_INPUT_TYPE_CAMERA;
-   inp->std = V4L2_STD_ALL;
+   inp->std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM;
 
/* Get status of video decoder */
decoder_call(zr, video, g_input_status, >status);
-- 
2.26.2

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


[PATCH RFT/RFC v2 15/47] staging: media: zoran: do not print random guest 0

2020-09-25 Thread Corentin Labbe
The slot 0 of guest is never initialized and so we print later random
data.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 04ba22a915f0..dfc2551f2d71 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -158,6 +158,9 @@ static void dump_guests(struct zoran *zr)
if (zr36067_debug > 2) {
int i, guest[8];
 
+   /* do not print random data */
+   guest[0] = 0;
+
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest[i] = post_office_read(zr, i, 0);
 
@@ -170,6 +173,10 @@ void detect_guest_activity(struct zoran *zr)
int timeout, i, j, res, guest[8], guest0[8], change[8][3];
ktime_t t0, t1;
 
+   /* do not print random data */
+   guest[0] = 0;
+   guest0[0] = 0;
+
dump_guests(zr);
pci_info(zr->pci_dev, "Detecting guests activity, please wait...\n");
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
-- 
2.26.2

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


[PATCH RFT/RFC v2 00/47] staging: media: bring back zoran driver

2020-09-25 Thread Corentin Labbe
Hello

The zoran driver was removed in 5.3
The main reason of the removing was lack of motivation to convert it to
VB2
Since I need it, I worked on bringing it back.

So the plan to achieve it was:
- clean up the coding style.
- convert old usage/API
- clean unused code
- convert to VB2

I have tried to split a bit the VB2 patch (by adding/removing code in
another patch), but the result is unfortunately still a big patch.

The result of this serie is a working zoran driver.
Furthermore it is now compliant to v4l-compliance.

In the process some old (useless) feature (fbuf, overlay) was removed
for simplifying maintenance.

The zoran hardware support MJPEG decompression, but this feature is
temporarily disabled by this serie.
But basically, this feature was unusable, since the only tool which
permitted to use it was a mplayer option.
But this mplayer option no longer compile (probably since a long time)
and is such a hack (a copy of some private ffmpeg structure) that it is
unfixable.
Happily, when I started to work on zoran, a patch was posted on ffmpeg
ML which permit it to output non-raw video stream (and so MJPEG for
zoran case).
But the zoran hw does not like some part of JPEG header it receives, so
a filter need to be written.
Anyway, this disabling is not a regression, since this feature was not
usable since a long time.

Since the driver was in staging, I targeted staging, but probably the
driver is in a sufficient good shape to target media and bypass staging.

This driver is tested on a DC10+ (on x86). Tests on different hardware
are welcome.

I would like to thanks all people that helped me to achieve this (mostly
#v4l)

Regards

PS: this serie is resent a bit soon since linux-media didnt get some patch
and cover letter

Changes since RFC1
- removed fallthough patch
- removed unsplit lines patch
- fixed line size in "Use DMA coherent for stat_com" patch

Corentin Labbe (47):
  staging: media: Revert "media: zoran: remove deprecated driver"
  MAINTAINERS: change maintainer of the zoran driver
  staging: media: zoran: datasheet is no longer available from zoran.com
  staging: media: zoran: Documentation: fix typo
  staging: media: zoran: fix checkpatch issue
  staging: media: zoran: do not forward declare zr36057_init_vfe
  staging: media: zoran: convert all error dprintk to pci_err/pr_err
  staging: media: zoran: convert dprintk warn
  staging: media: zoran: convert dprintk info to pci_info
  staging: media: zoran: convert dprintk debug
  staging: media: zoran: zoran_device.c: convert pr_x to pci_x
  staging: media: zoran: remove proc_fs
  staging: media: zoran: use VFL_TYPE_VIDEO
  staging: media: zoran: use v4l2_buffer_set_timestamp
  staging: media: zoran: do not print random guest 0
  staging: media: zoran: move buffer_size out of zoran_fh
  staging: media: zoran: move v4l_settings out of zoran_fh
  staging: media: zoran: move jpg_settings out of zoran_fh
  staging: media: zoran: move overlay_settings out of zoran_fh
  staging: media: zoran: Use video_drvdata to get struct zoran
  staging: media: zoran: Change zoran_v4l_set_format parameter from
zoran_fh to zoran
  staging: media: zoran: remove overlay
  staging: media: zoran: Use DMA coherent for stat_com
  staging: media: zoran: use ZR_NORM
  staging: media: zoran: zoran does not support STD_ALL
  staging: media: zoran: convert irq to pci irq
  staging: media: zoran: convert zoran alloc to devm
  staging: media: zoran: convert mdelay to udelay
  staging: media: zoran: use devm for videocodec_master alloc
  staging: media: zoran: use pci_request_regions
  staging: media: zoran: use devm_ioremap
  staging: media: zoran: add stat_com buffer
  staging: media: zoran: constify struct tvnorm
  staging: media: zoran: constify codec_name
  staging: media: zoran: Add more check for compliance
  staging: media: zoran: Add vb_queue
  staging: media: zoran: disable output
  staging: media: zoran: device support only 32bit DMA address
  staging: media: zoran: enable makefile
  staging: media: zoran: remove framebuffer support
  staging: media: zoran: add vidioc_g_parm
  staging: media: zoran: remove test_interrupts
  staging: media: zoran: fix use of buffer_size and sizeimage
  staging: media: zoran: fix some compliance test
  staging: media: zoran: remove deprecated .vidioc_g_jpegcomp
  staging: media: zoran: convert to vb2
  staging: media: zoran: update TODO

 Documentation/media/v4l-drivers/zoran.rst  |  575 +
 MAINTAINERS|   10 +
 drivers/staging/media/Kconfig  |2 +
 drivers/staging/media/Makefile |1 +
 drivers/staging/media/zoran/Kconfig|   76 ++
 drivers/staging/media/zoran/Makefile   |7 +
 drivers/staging/media/zoran/TODO   |   19 +
 drivers/staging/media/zoran/videocodec.c   |  330 +
 drivers/staging/media/zoran/videocodec.h   |  308 +
 drivers/staging/media/zoran/zoran.h|  320 +
 drivers/staging/medi

[PATCH RFT/RFC v2 24/47] staging: media: zoran: use ZR_NORM

2020-09-25 Thread Corentin Labbe
Instead of using hardcoded numbers, let's use some define for ZR NORM.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h| 4 
 drivers/staging/media/zoran/zoran_card.c   | 8 
 drivers/staging/media/zoran/zoran_driver.c | 6 +++---
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 8f3faa4eb60f..87ca324f6ec2 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -22,6 +22,10 @@
 #include 
 #include 
 
+#define ZR_NORM_PAL 0
+#define ZR_NORM_NTSC 1
+#define ZR_NORM_SECAM 2
+
 struct zoran_sync {
unsigned long frame;/* number of buffer that has been free'd */
unsigned long length;   /* number of code bytes in buffer (capture 
only) */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 9fe2bc2b036a..8be7f8f0a020 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -911,18 +911,18 @@ static int zr36057_init(struct zoran *zr)
default_norm = 0;
if (default_norm == 0) {
zr->norm = V4L2_STD_PAL;
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
} else if (default_norm == 1) {
zr->norm = V4L2_STD_NTSC;
-   zr->timing = zr->card.tvn[1];
+   zr->timing = zr->card.tvn[ZR_NORM_NTSC];
} else {
zr->norm = V4L2_STD_SECAM;
-   zr->timing = zr->card.tvn[2];
+   zr->timing = zr->card.tvn[ZR_NORM_SECAM];
}
if (!zr->timing) {
pci_warn(zr->pci_dev, "%s - default TV standard not supported 
by hardware. PAL will be used.\n", __func__);
zr->norm = V4L2_STD_PAL;
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
}
 
if (default_input > zr->card.inputs - 1) {
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index b910ad136b84..858e0910884c 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1033,11 +1033,11 @@ static int zoran_set_norm(struct zoran *zr, v4l2_std_id 
norm)
}
 
if (norm & V4L2_STD_SECAM)
-   zr->timing = zr->card.tvn[2];
+   zr->timing = zr->card.tvn[ZR_NORM_SECAM];
else if (norm & V4L2_STD_NTSC)
-   zr->timing = zr->card.tvn[1];
+   zr->timing = zr->card.tvn[ZR_NORM_NTSC];
else
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
 
decoder_call(zr, video, s_std, norm);
encoder_call(zr, video, s_std_output, norm);
-- 
2.26.2

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


[PATCH RFT/RFC v2 06/47] staging: media: zoran: do not forward declare zr36057_init_vfe

2020-09-25 Thread Corentin Labbe
move function for avoiding forward declaration

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 44 +++---
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index cbacfa4ea2d0..cf3e2b5e4b4e 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -55,7 +55,27 @@ static bool lml33dpath;  /* default = 0
 module_param(lml33dpath, bool, 0644);
 MODULE_PARM_DESC(lml33dpath, "Use digital path capture mode (on LML33 cards)");
 
-static void zr36057_init_vfe(struct zoran *zr);
+/*
+ * initialize video front end
+ */
+static void zr36057_init_vfe(struct zoran *zr)
+{
+   u32 reg;
+
+   reg = btread(ZR36057_VFESPFR);
+   reg |= ZR36057_VFESPFR_LittleEndian;
+   reg &= ~ZR36057_VFESPFR_VCLKPol;
+   reg |= ZR36057_VFESPFR_ExtFl;
+   reg |= ZR36057_VFESPFR_TopField;
+   btwrite(reg, ZR36057_VFESPFR);
+   reg = btread(ZR36057_VDCR);
+   if (pci_pci_problems & PCIPCI_TRITON)
+   // || zr->revision < 1) // Revision 1 has also Triton support
+   reg &= ~ZR36057_VDCR_Triton;
+   else
+   reg |= ZR36057_VDCR_Triton;
+   btwrite(reg, ZR36057_VDCR);
+}
 
 /*
  * General Purpose I/O and Guest bus access
@@ -1491,25 +1511,3 @@ void zr36057_restart(struct zoran *zr)
btwrite((0x81 << 24) | 0x, ZR36057_GPPGCR1);
 }
 
-/*
- * initialize video front end
- */
-
-static void zr36057_init_vfe(struct zoran *zr)
-{
-   u32 reg;
-
-   reg = btread(ZR36057_VFESPFR);
-   reg |= ZR36057_VFESPFR_LittleEndian;
-   reg &= ~ZR36057_VFESPFR_VCLKPol;
-   reg |= ZR36057_VFESPFR_ExtFl;
-   reg |= ZR36057_VFESPFR_TopField;
-   btwrite(reg, ZR36057_VFESPFR);
-   reg = btread(ZR36057_VDCR);
-   if (pci_pci_problems & PCIPCI_TRITON)
-   // || zr->revision < 1) // Revision 1 has also Triton support
-   reg &= ~ZR36057_VDCR_Triton;
-   else
-   reg |= ZR36057_VDCR_Triton;
-   btwrite(reg, ZR36057_VDCR);
-}
-- 
2.26.2

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


[PATCH RFT/RFC v2 29/47] staging: media: zoran: use devm for videocodec_master alloc

2020-09-25 Thread Corentin Labbe
Let's use devm allocations for videocodec, this simplify code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index fe0c5a7c967c..a3e7b0027d69 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -996,18 +996,10 @@ static void zoran_remove(struct pci_dev *pdev)
goto exit_free;
 
/* unregister videocodec bus */
-   if (zr->codec) {
-   struct videocodec_master *master = zr->codec->master_data;
-
+   if (zr->codec)
videocodec_detach(zr->codec);
-   kfree(master);
-   }
-   if (zr->vfe) {
-   struct videocodec_master *master = zr->vfe->master_data;
-
+   if (zr->vfe)
videocodec_detach(zr->vfe);
-   kfree(master);
-   }
 
/* unregister i2c bus */
zoran_unregister_i2c(zr);
@@ -1036,7 +1028,7 @@ static struct videocodec_master 
*zoran_setup_videocodec(struct zoran *zr,
 {
struct videocodec_master *m = NULL;
 
-   m = kmalloc(sizeof(*m), GFP_KERNEL);
+   m = devm_kmalloc(>pci_dev->dev, sizeof(*m), GFP_KERNEL);
if (!m)
return m;
 
@@ -1245,7 +1237,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zr->codec = videocodec_attach(master_codec);
if (!zr->codec) {
pci_err(pdev, "%s - no codec found\n", __func__);
-   goto zr_free_codec;
+   goto zr_unreg_i2c;
}
if (zr->codec->type != zr->card.video_codec) {
pci_err(pdev, "%s - wrong codec\n", __func__);
@@ -1259,7 +1251,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zr->vfe = videocodec_attach(master_vfe);
if (!zr->vfe) {
pci_err(pdev, "%s - no VFE found\n", __func__);
-   goto zr_free_vfe;
+   goto zr_detach_codec;
}
if (zr->vfe->type != zr->card.video_vfe) {
pci_err(pdev, "%s = wrong VFE\n", __func__);
@@ -1280,12 +1272,8 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
 zr_detach_vfe:
videocodec_detach(zr->vfe);
-zr_free_vfe:
-   kfree(master_vfe);
 zr_detach_codec:
videocodec_detach(zr->codec);
-zr_free_codec:
-   kfree(master_codec);
 zr_unreg_i2c:
zoran_unregister_i2c(zr);
 zr_free_irq:
-- 
2.26.2

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


[PATCH RFT/RFC v2 42/47] staging: media: zoran: remove test_interrupts

2020-09-25 Thread Corentin Labbe
The test_interrupts function is useless, remove it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  3 ---
 drivers/staging/media/zoran/zoran_card.c   | 27 --
 drivers/staging/media/zoran/zoran_device.c | 16 -
 3 files changed, 46 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 0246635e0eac..fd27d1968e60 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -345,7 +345,6 @@ struct zoran {
struct zoran_buffer_col jpg_buffers;/* MJPEG buffers' info */
 
/* Additional stuff for testing */
-   int testing;
int jpeg_error;
int intr_counter_GIRQ1;
int intr_counter_GIRQ0;
@@ -372,8 +371,6 @@ struct zoran {
int running;
int buf_in_reserve;
 
-   wait_queue_head_t test_q;
-
dma_addr_t p_sc;
__le32 *stat_comb;
dma_addr_t p_scb;
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 28a403257bb9..89fbc114c368 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -858,31 +858,6 @@ void zoran_open_init_params(struct zoran *zr)
pci_err(zr->pci_dev, "%s internal error\n", __func__);
 
clear_interrupt_counters(zr);
-   zr->testing = 0;
-}
-
-static void test_interrupts(struct zoran *zr)
-{
-   DEFINE_WAIT(wait);
-   int timeout, icr;
-
-   clear_interrupt_counters(zr);
-
-   zr->testing = 1;
-   icr = btread(ZR36057_ICR);
-   btwrite(0x7800 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
-   prepare_to_wait(>test_q, , TASK_INTERRUPTIBLE);
-   timeout = schedule_timeout(HZ);
-   finish_wait(>test_q, );
-   btwrite(0, ZR36057_ICR);
-   btwrite(0x7800, ZR36057_ISR);
-   zr->testing = 0;
-   pci_info(zr->pci_dev, "Testing interrupts...\n");
-   if (timeout)
-   pci_info(zr->pci_dev, ": time spent: %d\n", 1 * HZ - timeout);
-   if (zr36067_debug > 1)
-   print_interrupts(zr);
-   btwrite(icr, ZR36057_ICR);
 }
 
 static int zr36057_init(struct zoran *zr)
@@ -896,7 +871,6 @@ static int zr36057_init(struct zoran *zr)
 
init_waitqueue_head(>v4l_capq);
init_waitqueue_head(>jpg_capq);
-   init_waitqueue_head(>test_q);
zr->jpg_buffers.allocated = 0;
zr->v4l_buffers.allocated = 0;
 
@@ -977,7 +951,6 @@ static int zr36057_init(struct zoran *zr)
zoran_init_hardware(zr);
if (zr36067_debug > 2)
detect_guest_activity(zr);
-   test_interrupts(zr);
if (!pass_through) {
decoder_call(zr, video, s_stream, 0);
encoder_call(zr, video, s_routing, 2, 0, 0);
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index fb318449d784..c090d7166caa 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -1109,22 +1109,6 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
struct zoran *zr = dev_id;
unsigned long flags;
 
-   if (zr->testing) {
-   /* Testing interrupts */
-   spin_lock_irqsave(>spinlock, flags);
-   while ((stat = count_reset_interrupt(zr))) {
-   if (count++ > 100) {
-   btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
-   pci_err(zr->pci_dev, "IRQ lockup while testing, 
isr=0x%08x, cleared int mask\n",
-   stat);
-   wake_up_interruptible(>test_q);
-   }
-   }
-   zr->last_isr = stat;
-   spin_unlock_irqrestore(>spinlock, flags);
-   return IRQ_HANDLED;
-   }
-
spin_lock_irqsave(>spinlock, flags);
while (1) {
/* get/clear interrupt status bits */
-- 
2.26.2

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


[PATCH RFT/RFC v2 07/47] staging: media: zoran: convert all error dprintk to pci_err/pr_err

2020-09-25 Thread Corentin Labbe
This patch converts all errors dprintk to pci_err/pr_err.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/videocodec.c   |  39 +--
 drivers/staging/media/zoran/zoran_card.c   |  96 ++
 drivers/staging/media/zoran/zoran_device.c |  28 +-
 drivers/staging/media/zoran/zoran_driver.c | 334 +
 drivers/staging/media/zoran/zoran_procfs.c |   4 +-
 drivers/staging/media/zoran/zr36016.c  |  39 +--
 drivers/staging/media/zoran/zr36050.c  |  10 +-
 drivers/staging/media/zoran/zr36060.c  |  24 +-
 8 files changed, 145 insertions(+), 429 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.c 
b/drivers/staging/media/zoran/videocodec.c
index 3a2f0c450a44..28031d3fd757 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -62,7 +62,7 @@ struct videocodec *videocodec_attach(struct videocodec_master 
*master)
int res;
 
if (!master) {
-   dprintk(1, KERN_ERR "videocodec_attach: no data\n");
+   pr_err("%s: no data\n", __func__);
return NULL;
}
 
@@ -70,9 +70,7 @@ struct videocodec *videocodec_attach(struct videocodec_master 
*master)
master->name, master->flags, master->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_attach: no device available\n");
+   pr_err("%s: no device available\n", __func__);
return NULL;
}
 
@@ -120,7 +118,7 @@ struct videocodec *videocodec_attach(struct 
videocodec_master *master)
h = h->next;
}
 
-   dprintk(1, KERN_ERR "videocodec_attach: no codec found!\n");
+   pr_err("%s: no codec found!\n", __func__);
return NULL;
 
  out_module_put:
@@ -138,7 +136,7 @@ int videocodec_detach(struct videocodec *codec)
int res;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_detach: no data\n");
+   pr_err("%s: no data\n", __func__);
return -EINVAL;
}
 
@@ -146,8 +144,7 @@ int videocodec_detach(struct videocodec *codec)
codec->name, codec->type, codec->flags, codec->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR "videocodec_detach: no device left...\n");
+   pr_err("%s: no device left...\n", __func__);
return -ENXIO;
}
 
@@ -161,10 +158,7 @@ int videocodec_detach(struct videocodec *codec)
dprintk(3, "%s: '%s'\n", __func__, 
a->codec->name);
a->codec->master_data = NULL;
} else {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_detach: '%s'\n",
-   a->codec->name);
+   pr_err("%s: '%s'\n", __func__, 
a->codec->name);
a->codec->master_data = NULL;
}
if (!prev) {
@@ -186,7 +180,7 @@ int videocodec_detach(struct videocodec *codec)
h = h->next;
}
 
-   dprintk(1, KERN_ERR "videocodec_detach: given codec not found!\n");
+   pr_err("%s: given codec not found!\n", __func__);
return -EINVAL;
 }
 EXPORT_SYMBOL(videocodec_detach);
@@ -196,7 +190,7 @@ int videocodec_register(const struct videocodec *codec)
struct codec_list *ptr, *h = codeclist_top;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_register: no data!\n");
+   pr_err("%s: no data!\n", __func__);
return -EINVAL;
}
 
@@ -229,7 +223,7 @@ int videocodec_unregister(const struct videocodec *codec)
struct codec_list *prev = NULL, *h = codeclist_top;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_unregister: no data!\n");
+   pr_err("%s: no data!\n", __func__);
return -EINVAL;
}
 
@@ -238,19 +232,14 @@ int videocodec_unregister(const struct videocodec *codec)
codec->name, codec->type, codec->flags, codec->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_unregister: no device left...\n");
+   pr_err("%s: no device left...\n", __func__);
return -ENXIO;
}
 
while (h) {
if (codec == h->codec) {
if (h->attached) {
- 

[PATCH RFT/RFC v2 28/47] staging: media: zoran: convert mdelay to udelay

2020-09-25 Thread Corentin Labbe
As asked by checkpath, let's use udelay.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 0ecb044f8e8f..4c9f6eafd130 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -1332,9 +1332,9 @@ void zoran_init_hardware(struct zoran *zr)
 void zr36057_restart(struct zoran *zr)
 {
btwrite(0, ZR36057_SPGPPCR);
-   mdelay(1);
+   udelay(1000);
btor(ZR36057_SPGPPCR_SoftReset, ZR36057_SPGPPCR);
-   mdelay(1);
+   udelay(1000);
 
/* assert P_Reset */
btwrite(0, ZR36057_JPC);
-- 
2.26.2

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


[PATCH RFT/RFC v2 47/47] staging: media: zoran: update TODO

2020-09-25 Thread Corentin Labbe
Update the TODO of the zoran driver

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/TODO | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/TODO b/drivers/staging/media/zoran/TODO
index 54464095d0d7..6992540d3e53 100644
--- a/drivers/staging/media/zoran/TODO
+++ b/drivers/staging/media/zoran/TODO
@@ -1,4 +1,19 @@
-The zoran driver is marked deprecated. It will be removed
-around May 2019 unless someone is willing to update this
-driver to the latest V4L2 frameworks (especially the vb2
-framework).
+
+How to test the zoran driver:
+- RAW capture
+   mplayer tv:///dev/video0 -tv driver=v4l2
+
+- MJPEG capture (compression)
+   mplayer tv:///dev/video0 -tv driver=v4l2:outfmt=mjpeg
+   TODO: need two test for both Dcim path
+
+- MJPEG play (decompression)
+   ffmpeg -i test.avi -vcodec mjpeg -an -f v4l2 /dev/video0
+   Note: only recent ffmpeg has the ability of sending non-raw video via 
v4l2
+
+   The original way of sending video was via mplayer vo_zr/vo_zr2, but it 
does not compile
+   anymore and is a dead end (usage of some old private ffmpeg structures).
+
+TODO
+- fix the v4l compliance "TRY_FMT cannot handle an invalid pixelformat"
+- Filter JPEG data to made output work
-- 
2.26.2

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


[PATCH RFT/RFC v2 18/47] staging: media: zoran: move jpg_settings out of zoran_fh

2020-09-25 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the jpg_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|   2 -
 drivers/staging/media/zoran/zoran_driver.c | 103 ++---
 2 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index a529b49888c6..7e6e03563a2a 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -216,8 +216,6 @@ struct zoran_fh {
enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
struct zoran_buffer_col buffers;/* buffers' info */
-
-   struct zoran_jpg_settings jpg_settings; /* structure with a lot of 
things to play with */
 };
 
 struct card_info {
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index e60db53c0359..27dcf899b723 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -587,9 +587,7 @@ static int zoran_jpg_queue_frame(struct zoran_fh *fh, int 
num,
}
 
/* what is the codec mode right now? */
-   if (zr->codec_mode == BUZ_MODE_IDLE) {
-   zr->jpg_settings = fh->jpg_settings;
-   } else if (zr->codec_mode != mode) {
+   if (zr->codec_mode != BUZ_MODE_IDLE && zr->codec_mode != mode) {
/* wrong codec mode active - invalid */
pci_err(zr->pci_dev, "%s - codec in wrong mode\n", __func__);
return -EINVAL;
@@ -751,9 +749,6 @@ static void zoran_open_init_session(struct zoran_fh *fh)
fh->overlay_settings.format = zr->overlay_settings.format;
fh->overlay_active = ZORAN_FREE;
 
-   /* jpg settings */
-   fh->jpg_settings = zr->jpg_settings;
-
/* buffers */
memset(>buffers, 0, sizeof(fh->buffers));
for (i = 0; i < MAX_FRAME; i++) {
@@ -1237,11 +1232,11 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
}
 
/* which fields are these? */
-   if (fh->jpg_settings.TmpDcm != 1)
-   buf->field = fh->jpg_settings.odd_even ?
+   if (zr->jpg_settings.TmpDcm != 1)
+   buf->field = zr->jpg_settings.odd_even ?
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
else
-   buf->field = fh->jpg_settings.odd_even ?
+   buf->field = zr->jpg_settings.odd_even ?
V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT;
 
break;
@@ -1391,18 +1386,18 @@ static int zoran_enum_fmt_vid_overlay(struct file 
*file, void *__fh,
 static int zoran_g_fmt_vid_out(struct file *file, void *__fh,
   struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
+   struct zoran *zr = video_drvdata(file);
 
-   fmt->fmt.pix.width = fh->jpg_settings.img_width / 
fh->jpg_settings.HorDcm;
-   fmt->fmt.pix.height = fh->jpg_settings.img_height * 2 /
-   (fh->jpg_settings.VerDcm * fh->jpg_settings.TmpDcm);
-   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
+   fmt->fmt.pix.width = zr->jpg_settings.img_width / 
zr->jpg_settings.HorDcm;
+   fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
+   (zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
+   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
-   if (fh->jpg_settings.TmpDcm == 1)
-   fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+   if (zr->jpg_settings.TmpDcm == 1)
+   fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT);
else
-   fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+   fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
fmt->fmt.pix.bytesperline = 0;
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -1471,15 +1466,14 @@ static int zoran_try_fmt_vid_overlay(struct file *file, 
void *__fh,
 static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
 struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
struct zoran_jpg_settings settings;
int res = 0;
 
if (fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
-   settings = fh->jpg_settings;
+   settings = zr->jpg_settings;
 
/* we actua

[PATCH RFT/RFC v2 31/47] staging: media: zoran: use devm_ioremap

2020-09-25 Thread Corentin Labbe
Using devm_ioremap simplify code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index f4639324bace..147bef1df33c 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1010,7 +1010,6 @@ static void zoran_remove(struct pci_dev *pdev)
pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
-   iounmap(zr->zr36057_mem);
pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
@@ -1165,7 +1164,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (err)
goto zr_unreg;
 
-   zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
+   zr->zr36057_mem = devm_ioremap(>dev, pci_resource_start(pdev, 0), 
pci_resource_len(pdev, 0));
if (!zr->zr36057_mem) {
pci_err(pdev, "%s() - ioremap failed\n", __func__);
goto zr_pci_release;
@@ -1181,7 +1180,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
} else {
pci_err(pdev, "%s - cannot assign IRQ, error code 
%d\n", __func__, result);
}
-   goto zr_unmap;
+   goto zr_pci_release;
}
 
/* set PCI latency timer */
@@ -1284,8 +1283,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 zr_free_irq:
btwrite(0, ZR36057_SPGPPCR);
pci_free_irq(zr->pci_dev, 0, zr);
-zr_unmap:
-   iounmap(zr->zr36057_mem);
 zr_pci_release:
pci_release_regions(pdev);
 zr_unreg:
-- 
2.26.2

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


[PATCH RFT/RFC v2 30/47] staging: media: zoran: use pci_request_regions

2020-09-25 Thread Corentin Labbe
Use pci_request_regions so now we can see zoran in /proc/iomem.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index a3e7b0027d69..f4639324bace 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1011,6 +1011,7 @@ static void zoran_remove(struct pci_dev *pdev)
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
+   pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
 exit_free:
@@ -1160,10 +1161,14 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
 zr->card.name, zr->id);
 
+   err = pci_request_regions(pdev, ZR_DEVNAME(zr));
+   if (err)
+   goto zr_unreg;
+
zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
if (!zr->zr36057_mem) {
pci_err(pdev, "%s() - ioremap failed\n", __func__);
-   goto zr_unreg;
+   goto zr_pci_release;
}
 
result = pci_request_irq(pdev, 0, zoran_irq, NULL, zr, ZR_DEVNAME(zr));
@@ -1281,6 +1286,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
pci_free_irq(zr->pci_dev, 0, zr);
 zr_unmap:
iounmap(zr->zr36057_mem);
+zr_pci_release:
+   pci_release_regions(pdev);
 zr_unreg:
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
-- 
2.26.2

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


[PATCH RFT/RFC v2 14/47] staging: media: zoran: use v4l2_buffer_set_timestamp

2020-09-25 Thread Corentin Labbe
The ns_to_timeval function is removed, so replace it with
v4l2_buffer_set_timestamp().

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 0d6c58a4161e..e74fd6a62606 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1197,7 +1197,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
fh->buffers.buffer[num].state == BUZ_STATE_USER) {
buf->sequence = fh->buffers.buffer[num].bs.seq;
buf->flags |= V4L2_BUF_FLAG_DONE;
-   buf->timestamp = 
ns_to_timeval(fh->buffers.buffer[num].bs.ts);
+   v4l2_buffer_set_timestamp(buf, 
fh->buffers.buffer[num].bs.ts);
} else {
buf->flags |= V4L2_BUF_FLAG_QUEUED;
}
@@ -1228,7 +1228,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
if (fh->buffers.buffer[num].state == BUZ_STATE_DONE ||
fh->buffers.buffer[num].state == BUZ_STATE_USER) {
buf->sequence = fh->buffers.buffer[num].bs.seq;
-   buf->timestamp = 
ns_to_timeval(fh->buffers.buffer[num].bs.ts);
+   v4l2_buffer_set_timestamp(buf, 
fh->buffers.buffer[num].bs.ts);
buf->bytesused = fh->buffers.buffer[num].bs.length;
buf->flags |= V4L2_BUF_FLAG_DONE;
} else {
-- 
2.26.2

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


[PATCH RFT/RFC v2 02/47] MAINTAINERS: change maintainer of the zoran driver

2020-09-25 Thread Corentin Labbe
Add myself as maintainer.

Signed-off-by: Corentin Labbe 
---
 Documentation/media/v4l-drivers/zoran.rst  | 22 +++---
 MAINTAINERS| 10 ++
 drivers/staging/media/zoran/zoran_card.c   |  5 -
 drivers/staging/media/zoran/zoran_card.h   |  5 -
 drivers/staging/media/zoran/zoran_device.c |  5 -
 drivers/staging/media/zoran/zoran_device.h |  5 -
 6 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/Documentation/media/v4l-drivers/zoran.rst 
b/Documentation/media/v4l-drivers/zoran.rst
index d2724a863d1d..a0586514cd8a 100644
--- a/Documentation/media/v4l-drivers/zoran.rst
+++ b/Documentation/media/v4l-drivers/zoran.rst
@@ -549,21 +549,13 @@ at high verbosity. See 'Contacting' on how to contact the 
developers.
 Maintainers/Contacting
 --
 
-The driver is currently maintained by Laurent Pinchart and Ronald Bultje
-( and ). For bug
-reports or questions, please contact the mailinglist instead of the developers
-individually. For user questions (i.e. bug reports or how-to questions), send
-an email to , for developers (i.e. if you want to
-help programming), send an email to . See
-http://www.sf.net/projects/mjpeg/ for subscription information.
-
-For bug reports, be sure to include all the information as described in
-the section 'It hangs/crashes/fails/whatevers! Help!'. Please make sure
-you're using the latest version (http://mjpeg.sf.net/driver-zoran/).
-
-Previous maintainers/developers of this driver include Serguei Miridonov
-, Wolfgang Scherr , Dave Perks
- and Rainer Johanni .
+Previous maintainers/developers of this driver are
+- Laurent Pinchart 
+- Ronald Bultje rbul...@ronald.bitfreak.net
+- Serguei Miridonov 
+- Wolfgang Scherr 
+- Dave Perks 
+- Rainer Johanni 
 
 Driver's License
 
diff --git a/MAINTAINERS b/MAINTAINERS
index d3126fc2cca2..f2ece9826be3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19233,6 +19233,16 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs.git
 F: Documentation/filesystems/zonefs.rst
 F: fs/zonefs/
 
+ZR36067 VIDEO FOR LINUX DRIVER
+M: Corentin Labbe 
+L: mjpeg-us...@lists.sourceforge.net
+L: linux-me...@vger.kernel.org
+S: Maintained
+W: http://mjpeg.sourceforge.net/driver-zoran/
+Q: https://patchwork.linuxtv.org/project/linux-media/list/
+F: drivers/staging/media/zoran/
+F: Documentation/media/v4l-drivers/zoran.rst
+
 ZPOOL COMPRESSED PAGE STORAGE API
 M: Dan Streetman 
 L: linux...@kvack.org
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index ea10523194e8..d2f82894e8ee 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_card.h 
b/drivers/staging/media/zoran/zoran_card.h
index 0cdb7d34926d..53ed511ce546 100644
--- a/drivers/staging/media/zoran/zoran_card.h
+++ b/drivers/staging/media/zoran/zoran_card.h
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 22b27632762d..04162be80420 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_device.h 
b/drivers/staging/media/zoran/zoran_device.h
index a507aaad4ebb..816d48b09be9 100644
--- a/drivers/staging/media/zoran/zoran_device.h
+++ b/drivers/staging/media/zoran/zoran_device.h
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published

[PATCH RFT/RFC v2 32/47] staging: media: zoran: add stat_com buffer

2020-09-25 Thread Corentin Labbe
This patch adds the allocation of the stat_com buffer which be used
later.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h  |  2 ++
 drivers/staging/media/zoran/zoran_card.c | 13 -
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 87ca324f6ec2..c73b7e7fd5e1 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -357,6 +357,8 @@ struct zoran {
wait_queue_head_t test_q;
 
dma_addr_t p_sc;
+   __le32 *stat_comb;
+   dma_addr_t p_scb;
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 147bef1df33c..756705a34e2b 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -951,6 +951,14 @@ static int zr36057_init(struct zoran *zr)
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
 
+   zr->stat_comb = dma_alloc_coherent(>pci_dev->dev,
+  BUZ_NUM_STAT_COM * sizeof(u32) * 2,
+  >p_scb, GFP_KERNEL);
+   if (!zr->stat_comb) {
+   err = -ENOMEM;
+   goto exit_statcom;
+   }
+
/* Now add the template and register the device unit. */
*zr->video_dev = zoran_template;
zr->video_dev->v4l2_dev = >v4l2_dev;
@@ -964,7 +972,7 @@ static int zr36057_init(struct zoran *zr)
zr->video_dev->vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
-   goto exit_statcom;
+   goto exit_statcomb;
video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
@@ -979,6 +987,8 @@ static int zr36057_init(struct zoran *zr)
zr->initialized = 1;
return 0;
 
+exit_statcomb:
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 
2, zr->stat_comb, zr->p_scb);
 exit_statcom:
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
 exit_video:
@@ -1010,6 +1020,7 @@ static void zoran_remove(struct pci_dev *pdev)
pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 
2, zr->stat_comb, zr->p_scb);
pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
-- 
2.26.2

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


[PATCH RFT/RFC v2 19/47] staging: media: zoran: move overlay_settings out of zoran_fh

2020-09-25 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the overlay_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  1 -
 drivers/staging/media/zoran/zoran_device.c |  8 ++---
 drivers/staging/media/zoran/zoran_driver.c | 40 +-
 3 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 7e6e03563a2a..e9fef23a720c 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -211,7 +211,6 @@ struct zoran_fh {
 
enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
 
-   struct zoran_overlay_settings overlay_settings;
u32 *overlay_mask;  /* overlay mask */
enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 672b8d927e0f..139cfc683b98 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -508,10 +508,10 @@ void write_overlay_mask(struct zoran_fh *fh, struct 
v4l2_clip *vp, int count)
height += y;
y = 0;
}
-   if (x + width > fh->overlay_settings.width)
-   width = fh->overlay_settings.width - x;
-   if (y + height > fh->overlay_settings.height)
-   height = fh->overlay_settings.height - y;
+   if (x + width > zr->overlay_settings.width)
+   width = zr->overlay_settings.width - x;
+   if (y + height > zr->overlay_settings.height)
+   height = zr->overlay_settings.height - y;
 
/* ignore degenerate clips */
if (height <= 0)
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 27dcf899b723..3a59aa66436f 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -744,9 +744,7 @@ static void zoran_open_init_session(struct zoran_fh *fh)
map_mode_raw(fh);
 
/* take over the card's current settings */
-   fh->overlay_settings = zr->overlay_settings;
-   fh->overlay_settings.is_set = 0;
-   fh->overlay_settings.format = zr->overlay_settings.format;
+   zr->overlay_settings.is_set = 0;
fh->overlay_active = ZORAN_FREE;
 
/* buffers */
@@ -1005,7 +1003,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
return -EINVAL;
}
 
-   if (!fh->overlay_settings.format) {
+   if (!zr->overlay_settings.format) {
pci_err(zr->pci_dev, "%s - no overlay format set\n", __func__);
return -EINVAL;
}
@@ -1043,11 +1041,11 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
return -EINVAL;
}
 
-   fh->overlay_settings.x = x;
-   fh->overlay_settings.y = y;
-   fh->overlay_settings.width = width;
-   fh->overlay_settings.height = height;
-   fh->overlay_settings.clipcount = clipcount;
+   zr->overlay_settings.x = x;
+   zr->overlay_settings.y = y;
+   zr->overlay_settings.width = width;
+   zr->overlay_settings.height = height;
+   zr->overlay_settings.clipcount = clipcount;
 
/*
 * If an overlay is running, we have to switch it off
@@ -1069,7 +1067,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
 */
if (bitmap) {
/* fake value - it just means we want clips */
-   fh->overlay_settings.clipcount = 1;
+   zr->overlay_settings.clipcount = 1;
 
if (copy_from_user(fh->overlay_mask, bitmap,
   (width * height + 7) / 8)) {
@@ -1091,10 +1089,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
vfree(vcp);
}
 
-   fh->overlay_settings.is_set = 1;
-   if (fh->overlay_active != ZORAN_FREE &&
-   zr->overlay_active != ZORAN_FREE)
-   zr->overlay_settings = fh->overlay_settings;
+   zr->overlay_settings.is_set = 1;
 
if (on)
zr36057_overlay(zr, 1);
@@ -1135,18 +1130,17 @@ static int setup_overlay(struct zoran_fh *fh, int on)
zr36057_overlay(zr, 0);
zr->overlay_mask = NULL;
} else {
-   if (!zr->vbuf_base || !fh->overlay_settings.is_set) {
+   if (!zr->vbuf_base || !zr->overlay_settings.is_set) {
  

[PATCH RFT/RFC v2 04/47] staging: media: zoran: Documentation: fix typo

2020-09-25 Thread Corentin Labbe
Fix some typo in doc.

Signed-off-by: Corentin Labbe 
---
 Documentation/media/v4l-drivers/zoran.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/media/v4l-drivers/zoran.rst 
b/Documentation/media/v4l-drivers/zoran.rst
index a0586514cd8a..2b82b9a47a71 100644
--- a/Documentation/media/v4l-drivers/zoran.rst
+++ b/Documentation/media/v4l-drivers/zoran.rst
@@ -119,7 +119,7 @@ Pinnacle/Miro DC10+
 * Analog Devices adv7176 TV encoder
 
 Drivers to use: videodev, i2c-core, i2c-algo-bit,
-videocodec, sa7110, adv7175, zr36060, zr36067
+videocodec, saa7110, adv7175, zr36060, zr36067
 
 Inputs/outputs: Composite, S-video and Internal
 
@@ -280,7 +280,7 @@ Samsung ks0127 TV decoder
 What the TV encoder can do an what not
 --
 
-The TV encoder are doing the "same" as the decoder, but in the oder direction.
+The TV encoder are doing the "same" as the decoder, but in the other direction.
 You feed them digital data and the generate a Composite or SVHS signal.
 For information about the colorsystems and TV norm take a look in the
 TV decoder section.
-- 
2.26.2

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


[PATCH RFT/RFC v2 46/47] staging: media: zoran: convert to vb2

2020-09-25 Thread Corentin Labbe
This is it! the ultimate last step, the vb2 conversion.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Kconfig|2 +-
 drivers/staging/media/zoran/zoran.h|   83 +-
 drivers/staging/media/zoran/zoran_card.c   |   45 +-
 drivers/staging/media/zoran/zoran_device.c |  488 ++-
 drivers/staging/media/zoran/zoran_driver.c | 1453 +---
 5 files changed, 137 insertions(+), 1934 deletions(-)

diff --git a/drivers/staging/media/zoran/Kconfig 
b/drivers/staging/media/zoran/Kconfig
index ddf38a931c01..492507030276 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -1,6 +1,6 @@
 config VIDEO_ZORAN
tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)"
-   depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 && VIRT_TO_BUS
+   depends on PCI && I2C_ALGOBIT && VIDEO_V4L2
depends on !ALPHA
select VIDEOBUF2_DMA_CONTIG
help
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index fd27d1968e60..372fadfd9a01 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -20,7 +20,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -29,13 +28,6 @@
 #define ZR_NORM_NTSC 1
 #define ZR_NORM_SECAM 2
 
-struct zoran_sync {
-   unsigned long frame;/* number of buffer that has been free'd */
-   unsigned long length;   /* number of code bytes in buffer (capture 
only) */
-   unsigned long seq;  /* frame sequence number */
-   u64 ts; /* timestamp */
-};
-
 struct zr_buffer {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer  vbuf;
@@ -111,18 +103,10 @@ enum zoran_codec_mode {
BUZ_MODE_STILL_DECOMPRESS   /* still frame conversion */
 };
 
-enum zoran_buffer_state {
-   BUZ_STATE_USER, /* buffer is owned by application */
-   BUZ_STATE_PEND, /* buffer is queued in pend[] ready to feed to 
I/O */
-   BUZ_STATE_DMA,  /* buffer is queued in dma[] for I/O */
-   BUZ_STATE_DONE  /* buffer is ready to return to application */
-};
-
 enum zoran_map_mode {
ZORAN_MAP_MODE_NONE,
ZORAN_MAP_MODE_RAW,
ZORAN_MAP_MODE_JPG_REC,
-#define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
ZORAN_MAP_MODE_JPG_PLAY,
 };
 
@@ -174,45 +158,6 @@ struct zoran_jpg_settings {
struct v4l2_jpegcompression jpg_comp;   /* JPEG-specific capture 
settings */
 };
 
-struct zoran_fh;
-
-struct zoran_mapping {
-   struct zoran_fh *fh;
-   atomic_t count;
-};
-
-struct zoran_buffer {
-   struct zoran_mapping *map;
-   enum zoran_buffer_state state;  /* state: unused/pending/dma/done */
-   struct zoran_sync bs;   /* DONE: info to return to application 
*/
-   union {
-   struct {
-   __le32 *frag_tab;   /* addresses of frag table */
-   u32 frag_tab_bus;   /* same value cached to save 
time in ISR */
-   } jpg;
-   struct {
-   char *fbuffer;  /* virtual address of frame 
buffer */
-   unsigned long fbuffer_phys;/* physical address of frame 
buffer */
-   unsigned long fbuffer_bus;/* bus address of frame 
buffer */
-   } v4l;
-   };
-};
-
-enum zoran_lock_activity {
-   ZORAN_FREE, /* free for use */
-   ZORAN_ACTIVE,   /* active but unlocked */
-   ZORAN_LOCKED,   /* locked */
-};
-
-/* buffer collections */
-struct zoran_buffer_col {
-   enum zoran_lock_activity active;/* feature currently in use? */
-   unsigned int num_buffers;
-   struct zoran_buffer buffer[MAX_FRAME];  /* buffers */
-   u8 allocated;   /* Flag if buffers are allocated */
-   u8 need_contiguous; /* Flag if contiguous buffers are needed */
-   /* only applies to jpg buffers, raw buffers are always contiguous */
-};
 
 struct zoran;
 
@@ -220,10 +165,6 @@ struct zoran;
 struct zoran_fh {
struct v4l2_fh fh;
struct zoran *zr;
-
-   enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
-
-   struct zoran_buffer_col buffers;/* buffers' info */
 };
 
 struct card_info {
@@ -281,7 +222,6 @@ struct zoran {
struct mutex lock;  /* file ops serialize lock */
 
u8 initialized; /* flag if zoran has been correctly initialized 
*/
-   int user;   /* number of current users */
struct card_info card;
const struct tvnorm *timing;
 
@@ -300,28 +240,12 @@ struct zoran {
/* Current buffer params */
unsigned int buffer_size;
 
-   wait_queue_head_t v4l_capq;
-
-   int v4l_memgrab_active; /* Memory grab is activated */
-
-   int v4l_grab_

[PATCH RFT/RFC v2 45/47] staging: media: zoran: remove deprecated .vidioc_g_jpegcomp

2020-09-25 Thread Corentin Labbe
This patchs removed the deprecated .vidioc_g_jpegcomp and replace it
with corresponding v4l2_ctrl_ops code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 22 ++
 drivers/staging/media/zoran/zoran_driver.c | 49 --
 2 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index d7b3efa9e39f..fe52be4292fe 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1066,6 +1066,25 @@ static void zoran_subdev_notify(struct v4l2_subdev *sd, 
unsigned int cmd, void *
GPIO(zr, 7, 1);
 }
 
+static int zoran_video_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct zoran *zr = container_of(ctrl->handler, struct zoran, hdl);
+
+   switch (ctrl->id) {
+   case V4L2_CID_JPEG_COMPRESSION_QUALITY:
+   zr->jpg_settings.jpg_comp.quality = ctrl->val;
+   return zoran_check_jpg_settings(zr, >jpg_settings, 0);
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = {
+   .s_ctrl = zoran_video_set_ctrl,
+};
+
 /*
  *   Scan for a Buz card (actually for the PCI controller ZR36057),
  *   request the irq and map the io memory
@@ -1106,6 +1125,9 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (v4l2_ctrl_handler_init(>hdl, 10))
goto zr_unreg;
zr->v4l2_dev.ctrl_handler = >hdl;
+   v4l2_ctrl_new_std(>hdl, _video_ctrl_ops,
+ V4L2_CID_JPEG_COMPRESSION_QUALITY, 0,
+ 100, 1, 50);
spin_lock_init(>spinlock);
mutex_init(>lock);
if (pci_enable_device(pdev))
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index ab9eec50abad..a6fb41d03186 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1849,53 +1849,6 @@ static int zoran_s_selection(struct file *file, void 
*__fh, struct v4l2_selectio
return res;
 }
 
-static int zoran_g_jpegcomp(struct file *file, void *__fh,
-   struct v4l2_jpegcompression *params)
-{
-   struct zoran *zr = video_drvdata(file);
-
-   memset(params, 0, sizeof(*params));
-
-   params->quality = zr->jpg_settings.jpg_comp.quality;
-   params->APPn = zr->jpg_settings.jpg_comp.APPn;
-   memcpy(params->APP_data, zr->jpg_settings.jpg_comp.APP_data,
-  zr->jpg_settings.jpg_comp.APP_len);
-   params->APP_len = zr->jpg_settings.jpg_comp.APP_len;
-   memcpy(params->COM_data, zr->jpg_settings.jpg_comp.COM_data,
-  zr->jpg_settings.jpg_comp.COM_len);
-   params->COM_len = zr->jpg_settings.jpg_comp.COM_len;
-   params->jpeg_markers = zr->jpg_settings.jpg_comp.jpeg_markers;
-
-   return 0;
-}
-
-static int zoran_s_jpegcomp(struct file *file, void *__fh,
-   const struct v4l2_jpegcompression *params)
-{
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
-   int res = 0;
-   struct zoran_jpg_settings settings;
-
-   settings = zr->jpg_settings;
-
-   settings.jpg_comp = *params;
-
-   if (fh->buffers.active != ZORAN_FREE) {
-   pci_warn(zr->pci_dev, "VIDIOC_S_JPEGCOMP called while in 
playback/capture mode\n");
-   res = -EBUSY;
-   return res;
-   }
-
-   res = zoran_check_jpg_settings(zr, , 0);
-   if (res)
-   return res;
-   if (!fh->buffers.allocated)
-   zr->buffer_size = zoran_v4l2_calc_bufsize(>jpg_settings);
-   zr->jpg_settings.jpg_comp = settings.jpg_comp;
-   return res;
-}
-
 static __poll_t zoran_poll(struct file *file, poll_table  *wait)
 {
struct zoran_fh *fh = file->private_data;
@@ -2176,8 +2129,6 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_s_output= zoran_s_output,*/
.vidioc_g_std   = zoran_g_std,
.vidioc_s_std   = zoran_s_std,
-   .vidioc_g_jpegcomp  = zoran_g_jpegcomp,
-   .vidioc_s_jpegcomp  = zoran_s_jpegcomp,
.vidioc_reqbufs = zoran_reqbufs,
.vidioc_querybuf= zoran_querybuf,
.vidioc_qbuf= zoran_qbuf,
-- 
2.26.2

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


[PATCH RFT/RFC v2 40/47] staging: media: zoran: remove framebuffer support

2020-09-25 Thread Corentin Labbe
The framebuffer support is obsolete, so let's reduce code size.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  4 -
 drivers/staging/media/zoran/zoran_card.c   |  6 --
 drivers/staging/media/zoran/zoran_driver.c | 85 --
 3 files changed, 95 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 294e52d78e1b..0246635e0eac 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -299,10 +299,6 @@ struct zoran {
 
/* Current buffer params */
unsigned int buffer_size;
-   void *vbuf_base;
-   int vbuf_height, vbuf_width;
-   int vbuf_depth;
-   int vbuf_bytesperline;
 
wait_queue_head_t v4l_capq;
 
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 0a193283eefc..28a403257bb9 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -900,12 +900,6 @@ static int zr36057_init(struct zoran *zr)
zr->jpg_buffers.allocated = 0;
zr->v4l_buffers.allocated = 0;
 
-   zr->vbuf_base = (void *)vidmem;
-   zr->vbuf_width = 0;
-   zr->vbuf_height = 0;
-   zr->vbuf_depth = 0;
-   zr->vbuf_bytesperline = 0;
-
/* Avoid nonsense settings from user for default input/norm */
if (default_norm < 0 || default_norm > 2)
default_norm = 0;
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 43f7c0c02876..bcbe2c78ea16 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -881,48 +881,6 @@ static int zoran_close(struct file *file)
return 0;
 }
 
-static int setup_fbuffer(struct zoran_fh *fh, void *base, const struct 
zoran_format *fmt,
-int width, int height, int bytesperline)
-{
-   struct zoran *zr = fh->zr;
-
-   /* (Ronald) v4l/v4l2 guidelines */
-   if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
-   return -EPERM;
-
-   /*
-* Don't allow frame buffer overlay if PCI or AGP is buggy, or on
-  ALi Magik (that needs very low latency while the card needs a
-  higher value always)
-*/
-
-   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
-   return -ENXIO;
-
-   /* we need a bytesperline value, even if not given */
-   if (!bytesperline)
-   bytesperline = width * ((fmt->depth + 7) & ~7) / 8;
-
-   if (height <= 0 || width <= 0 || bytesperline <= 0) {
-   pci_err(zr->pci_dev, "%s - invalid height/width/bpl value 
(%d|%d|%d)\n",
-   __func__, width, height, bytesperline);
-   return -EINVAL;
-   }
-   if (bytesperline & 3) {
-   pci_err(zr->pci_dev, "%s - bytesperline (%d) must be 4-byte 
aligned\n",
-   __func__, bytesperline);
-   return -EINVAL;
-   }
-
-   zr->vbuf_base = (void *)((unsigned long)base & ~3);
-   zr->vbuf_height = height;
-   zr->vbuf_width = width;
-   zr->vbuf_depth = fmt->depth;
-   zr->vbuf_bytesperline = bytesperline;
-
-   return 0;
-}
-
 /* get the status of a buffer in the clients buffer queue */
 static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
struct v4l2_buffer *buf, int num)
@@ -1403,47 +1361,6 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
return res;
 }
 
-static int zoran_g_fbuf(struct file *file, void *__fh,
-   struct v4l2_framebuffer *fb)
-{
-   struct zoran *zr = video_drvdata(file);
-
-   memset(fb, 0, sizeof(*fb));
-   fb->base = zr->vbuf_base;
-   fb->fmt.width = zr->vbuf_width;
-   fb->fmt.height = zr->vbuf_height;
-   fb->fmt.bytesperline = zr->vbuf_bytesperline;
-   fb->fmt.colorspace = V4L2_COLORSPACE_SRGB;
-   fb->fmt.field = V4L2_FIELD_INTERLACED;
-   fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
-
-   return 0;
-}
-
-static int zoran_s_fbuf(struct file *file, void *__fh,
-   const struct v4l2_framebuffer *fb)
-{
-   struct zoran *zr = video_drvdata(file);
-   struct zoran_fh *fh = __fh;
-   int i, res = 0;
-   __le32 printformat = __cpu_to_le32(fb->fmt.pixelformat);
-
-   for (i = 0; i < NUM_FORMATS; i++)
-   if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
-   break;
-   if (i == NUM_FORMATS) {
-   pci_err(zr->pci_dev, "VIDIOC_S_FBUF - format=0x%x (%4.4s) not 
allowed\n",
-   fb->fmt.pixelformat,
-   (char *));
- 

[PATCH RFT/RFC v2 36/47] staging: media: zoran: Add vb_queue

2020-09-25 Thread Corentin Labbe
This patchs adds a vb_queue without using it.
This reduce the final VB2 conversion patch.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Kconfig|   1 +
 drivers/staging/media/zoran/zoran.h|  30 +++
 drivers/staging/media/zoran/zoran_card.c   |   7 +
 drivers/staging/media/zoran/zoran_driver.c | 233 +
 4 files changed, 271 insertions(+)

diff --git a/drivers/staging/media/zoran/Kconfig 
b/drivers/staging/media/zoran/Kconfig
index 34a18135ede0..ddf38a931c01 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -2,6 +2,7 @@ config VIDEO_ZORAN
tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)"
depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 && VIRT_TO_BUS
depends on !ALPHA
+   select VIDEOBUF2_DMA_CONTIG
help
  Say Y for support for MJPEG capture cards based on the Zoran
  36057/36067 PCI controller chipset. This includes the Iomega
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 727ba67afd56..294e52d78e1b 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -21,6 +21,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #define ZR_NORM_PAL 0
 #define ZR_NORM_NTSC 1
@@ -33,6 +36,18 @@ struct zoran_sync {
u64 ts; /* timestamp */
 };
 
+struct zr_buffer {
+   /* common v4l buffer stuff -- must be first */
+   struct vb2_v4l2_buffer  vbuf;
+   struct list_headqueue;
+};
+
+static inline struct zr_buffer *vb2_to_zr_buffer(struct vb2_buffer *vb)
+{
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+
+   return container_of(vbuf, struct zr_buffer, vbuf);
+}
 
 #define ZORAN_NAME"ZORAN"  /* name of the device */
 
@@ -104,6 +119,7 @@ enum zoran_buffer_state {
 };
 
 enum zoran_map_mode {
+   ZORAN_MAP_MODE_NONE,
ZORAN_MAP_MODE_RAW,
ZORAN_MAP_MODE_JPG_REC,
 #define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
@@ -250,6 +266,7 @@ struct zoran {
struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler hdl;
struct video_device *video_dev;
+   struct vb2_queue vq;
 
struct i2c_adapter i2c_adapter; /* */
struct i2c_algo_bit_data i2c_algo;  /* */
@@ -320,6 +337,7 @@ struct zoran {
unsigned long jpg_err_seq;  /* last seq_num before error */
unsigned long jpg_err_shift;
unsigned long jpg_queued_num;   /* count of frames queued since 
grab/play started */
+   unsigned long vbseq;
 
/* zr36057's code buffer table */
__le32 *stat_com;   /* stat_com[i] is indexed by 
dma_head/tail & BUZ_MASK_STAT_COM */
@@ -350,15 +368,23 @@ struct zoran {
int num_errors;
int JPEG_max_missed;
int JPEG_min_missed;
+   unsigned int prepared;
+   unsigned int queued;
 
u32 last_isr;
unsigned long frame_num;
+   int running;
+   int buf_in_reserve;
 
wait_queue_head_t test_q;
 
dma_addr_t p_sc;
__le32 *stat_comb;
dma_addr_t p_scb;
+   enum zoran_map_mode map_mode;
+   struct list_head queued_bufs;
+   spinlock_t queued_bufs_lock; /* Protects queued_bufs */
+   struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2];
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
@@ -376,3 +402,7 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 #define btaor(dat, mask, adr) btwrite((dat) | ((mask) & btread(adr)), adr)
 
 #endif
+
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+void zoran_queue_exit(struct zoran *zr);
+int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 49a1d9e084a8..fed368ba6fd1 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -970,6 +970,9 @@ static int zr36057_init(struct zoran *zr)
 * another day.
 */
zr->video_dev->vfl_dir = VFL_DIR_M2M;
+
+   zoran_queue_init(zr, >vq);
+
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
goto exit_statcomb;
@@ -1005,6 +1008,8 @@ static void zoran_remove(struct pci_dev *pdev)
if (!zr->initialized)
goto exit_free;
 
+   zoran_queue_exit(zr);
+
/* unregister videocodec bus */
if (zr->codec)
videocodec_detach(zr->codec);
@@ -1283,6 +1288,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (zr36057_init(zr) < 0)
goto zr_detach_vfe;
 
+   zr->map_mode = ZORAN_MAP_MODE_RAW;
+
return 0;
 
 zr_detach_vfe:
diff --git a/drivers/staging/media/zoran/zoran_driver.c 

[PATCH RFT/RFC v2 43/47] staging: media: zoran: fix use of buffer_size and sizeimage

2020-09-25 Thread Corentin Labbe
buffer_size was not set when it should be.
Furthermore, use it instead of recalculate it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 2 ++
 drivers/staging/media/zoran/zoran_driver.c | 9 ++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 89fbc114c368..d7b3efa9e39f 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -857,6 +857,8 @@ void zoran_open_init_params(struct zoran *zr)
if (i)
pci_err(zr->pci_dev, "%s internal error\n", __func__);
 
+   zr->buffer_size = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+
clear_interrupt_counters(zr);
 }
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 5dacbeac790b..021073ba08e6 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -407,6 +407,8 @@ static int zoran_v4l_set_format(struct zoran *zr, int 
width, int height,
 
bpp = (format->depth + 7) / 8;
 
+   zr->buffer_size = height * width * bpp;
+
/* Check against available buffer size */
if (height * width * bpp > zr->buffer_size) {
pci_err(zr->pci_dev, "%s - video buffer size (%d kB) is too 
small\n",
@@ -1100,7 +1102,7 @@ static int zoran_g_fmt_vid_out(struct file *file, void 
*__fh,
fmt->fmt.pix.width = zr->jpg_settings.img_width / 
zr->jpg_settings.HorDcm;
fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
(zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
-   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if (zr->jpg_settings.TmpDcm == 1)
fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
@@ -1125,7 +1127,7 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh,
 
fmt->fmt.pix.width = zr->v4l_settings.width;
fmt->fmt.pix.height = zr->v4l_settings.height;
-   fmt->fmt.pix.sizeimage = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
@@ -1194,6 +1196,7 @@ static int zoran_try_fmt_vid_out(struct file *file, void 
*__fh,
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 
fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize();
+   zr->buffer_size = fmt->fmt.pix.sizeimage;
fmt->fmt.pix.bytesperline = 0;
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
return res;
@@ -1352,7 +1355,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
 
/* tell the user the results/missing stuff */
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
-   fmt->fmt.pix.sizeimage = zr->v4l_settings.height * 
zr->v4l_settings.bytesperline;
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
-- 
2.26.2

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


[PATCH RFT/RFC v2 33/47] staging: media: zoran: constify struct tvnorm

2020-09-25 Thread Corentin Labbe
The structure tvnorm could be consified.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/videocodec.h   |  2 +-
 drivers/staging/media/zoran/zoran.h|  4 ++--
 drivers/staging/media/zoran/zoran_card.c   | 24 +++---
 drivers/staging/media/zoran/zoran_device.c |  4 ++--
 drivers/staging/media/zoran/zr36016.c  |  4 ++--
 drivers/staging/media/zoran/zr36050.c  |  4 ++--
 drivers/staging/media/zoran/zr36060.c  |  2 +-
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.h 
b/drivers/staging/media/zoran/videocodec.h
index 553af4ad431e..a049f3c2c68a 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -256,7 +256,7 @@ struct videocodec {
// set compression or decompression (or freeze, stop, standby, etc)
int (*set_mode)(struct videocodec *codec, int mode);
// setup picture size and norm (for the codec's video frontend)
-   int (*set_video)(struct videocodec *codec, struct tvnorm *norm,
+   int (*set_video)(struct videocodec *codec, const struct tvnorm *norm,
 struct vfe_settings *cap, struct vfe_polarity *pol);
// other control commands, also mmap setup etc.
int (*control)(struct videocodec *codec, int type, int size, void 
*data);
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index c73b7e7fd5e1..727ba67afd56 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -227,7 +227,7 @@ struct card_info {
} input[BUZ_MAX_INPUT];
 
v4l2_std_id norms;
-   struct tvnorm *tvn[3];  /* supported TV norms */
+   const struct tvnorm *tvn[3];/* supported TV norms */
 
u32 jpeg_int;   /* JPEG interrupt */
u32 vsync_int;  /* VSYNC interrupt */
@@ -266,7 +266,7 @@ struct zoran {
u8 initialized; /* flag if zoran has been correctly initialized 
*/
int user;   /* number of current users */
struct card_info card;
-   struct tvnorm *timing;
+   const struct tvnorm *timing;
 
unsigned short id;  /* number of this device */
char name[32];  /* name of this device */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 756705a34e2b..79783cbb919a 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -277,24 +277,24 @@ static char *codecid_to_modulename(u16 codecid)
 //  u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
 // };
 
-static struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
-static struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
-static struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
-static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
+static const struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
+static const struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
+static const struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
+static const struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
 
-static struct tvnorm f50ccir601_lml33 = { 864, 720, 75 + 34, 804, 625, 576, 18 
};
-static struct tvnorm f60ccir601_lml33 = { 858, 720, 57 + 34, 788, 525, 480, 16 
};
+static const struct tvnorm f50ccir601_lml33 = { 864, 720, 75 + 34, 804, 625, 
576, 18 };
+static const struct tvnorm f60ccir601_lml33 = { 858, 720, 57 + 34, 788, 525, 
480, 16 };
 
 /* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
-static struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };
-static struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 };
+static const struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };
+static const struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 
};
 
 /*
  * FIXME: I cannot swap U and V in saa7114, so i do one pixel left shift in 
zoran (75 -> 74)
  * (Maxim Yevtyushkin )
  */
-static struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74 + 54, 804, 625, 576, 
18 };
-static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 54, 788, 525, 480, 
16 };
+static const struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74 + 54, 804, 625, 
576, 18 };
+static const struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 54, 788, 525, 
480, 16 };
 
 /*
  * FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I 
copy Maxim's left
@@ -303,8 +303,8 @@ static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 
54, 788, 525, 480, 16
  * Christer's driver used the unshifted norms, though...
  * /Sam
  */
-static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 };
-static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 };
+static const struct tvnorm f50ccir601_avs6e

[PATCH RFT/RFC v2 44/47] staging: media: zoran: fix some compliance test

2020-09-25 Thread Corentin Labbe
Add TODO for "TRY_FMT cannot handle an invalid pixelformat"

We need to set pixelformat in some case.
We should also handle some minimum requirement.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 021073ba08e6..ab9eec50abad 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1217,9 +1217,12 @@ static int zoran_try_fmt_vid_cap(struct file *file, void 
*__fh,
if (zoran_formats[i].fourcc == fmt->fmt.pix.pixelformat)
break;
 
-   if (i == NUM_FORMATS)
+   if (i == NUM_FORMATS) {
+   /* TODO do not return here to fix the TRY_FMT cannot handle an 
invalid pixelformat*/
return -EINVAL;
+   }
 
+   fmt->fmt.pix.pixelformat = zoran_formats[i].fourcc;
fmt->fmt.pix.colorspace = zoran_formats[i].colorspace;
if (BUZ_MAX_HEIGHT < (fmt->fmt.pix.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
@@ -1332,6 +1335,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
if (i == NUM_FORMATS) {
pci_err(zr->pci_dev, "VIDIOC_S_FMT - unknown/unsupported format 
0x%x\n",
fmt->fmt.pix.pixelformat);
+   /* TODO do not return here to fix the TRY_FMT cannot handle an 
invalid pixelformat*/
return -EINVAL;
}
 
@@ -1341,10 +1345,16 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
res = -EBUSY;
return res;
}
+
+   fmt->fmt.pix.pixelformat = zoran_formats[i].fourcc;
if (fmt->fmt.pix.height > BUZ_MAX_HEIGHT)
fmt->fmt.pix.height = BUZ_MAX_HEIGHT;
if (fmt->fmt.pix.width > BUZ_MAX_WIDTH)
fmt->fmt.pix.width = BUZ_MAX_WIDTH;
+   if (fmt->fmt.pix.height < BUZ_MIN_HEIGHT)
+   fmt->fmt.pix.height = BUZ_MIN_HEIGHT;
+   if (fmt->fmt.pix.width < BUZ_MIN_WIDTH)
+   fmt->fmt.pix.width = BUZ_MIN_WIDTH;
 
map_mode_raw(fh);
 
-- 
2.26.2

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


[PATCH RFT/RFC v2 38/47] staging: media: zoran: device support only 32bit DMA address

2020-09-25 Thread Corentin Labbe
The zoran device only supports 32bit DMA address.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index dbdb1c4b0515..0a193283eefc 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -,6 +,12 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
int card_num;
const char *codec_name, *vfe_name;
unsigned int nr;
+   int err;
+
+   err = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (err)
+   return -ENODEV;
+   vb2_dma_contig_set_max_seg_size(>dev, DMA_BIT_MASK(32));
 
nr = zoran_num++;
if (nr >= BUZ_MAX) {
-- 
2.26.2

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


[PATCH RFT/RFC v2 20/47] staging: media: zoran: Use video_drvdata to get struct zoran

2020-09-25 Thread Corentin Labbe
Using video_drvdata() is proper and shorter than using directly
fh pointers.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 40 --
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 3a59aa66436f..518ba19e1e0a 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1320,8 +1320,7 @@ static int zoran_set_input(struct zoran *zr, int input)
 
 static int zoran_querycap(struct file *file, void *__fh, struct 
v4l2_capability *cap)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
@@ -1353,8 +1352,7 @@ static int zoran_enum_fmt(struct zoran *zr, struct 
v4l2_fmtdesc *fmt, int flag)
 static int zoran_enum_fmt_vid_cap(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_CAPTURE);
 }
@@ -1362,8 +1360,7 @@ static int zoran_enum_fmt_vid_cap(struct file *file, void 
*__fh,
 static int zoran_enum_fmt_vid_out(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_PLAYBACK);
 }
@@ -1371,8 +1368,7 @@ static int zoran_enum_fmt_vid_out(struct file *file, void 
*__fh,
 static int zoran_enum_fmt_vid_overlay(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_OVERLAY);
 }
@@ -1424,8 +1420,7 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh,
 static int zoran_g_fmt_vid_overlay(struct file *file, void *__fh,
   struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
fmt->fmt.win.w.left = zr->overlay_settings.x;
fmt->fmt.win.w.top = zr->overlay_settings.y;
@@ -1442,8 +1437,7 @@ static int zoran_g_fmt_vid_overlay(struct file *file, 
void *__fh,
 static int zoran_try_fmt_vid_overlay(struct file *file, void *__fh,
 struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH)
fmt->fmt.win.w.width = BUZ_MAX_WIDTH;
@@ -1647,8 +1641,8 @@ static int zoran_s_fmt_vid_out(struct file *file, void 
*__fh,
 static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
   struct v4l2_format *fmt)
 {
+   struct zoran *zr = video_drvdata(file);
struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
int i;
int res = 0;
 
@@ -1696,8 +1690,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
 static int zoran_g_fbuf(struct file *file, void *__fh,
struct v4l2_framebuffer *fb)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
memset(fb, 0, sizeof(*fb));
fb->base = zr->vbuf_base;
@@ -1716,8 +1709,8 @@ static int zoran_g_fbuf(struct file *file, void *__fh,
 static int zoran_s_fbuf(struct file *file, void *__fh,
const struct v4l2_framebuffer *fb)
 {
+   struct zoran *zr = video_drvdata(file);
struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
int i, res = 0;
__le32 printformat = __cpu_to_le32(fb->fmt.pixelformat);
 
@@ -2049,8 +2042,7 @@ static int zoran_streamoff(struct file *file, void *__fh, 
enum v4l2_buf_type typ
 
 static int zoran_g_std(struct file *file, void *__fh, v4l2_std_id *std)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
*std = zr->norm;
return 0;
@@ -2058,8 +2050,7 @@ static int zoran_g_std(struct file *file, void *__fh, 
v4l2_std_id *std)
 
 static int zoran_s_std(struct file *file, void *__fh, v4l2_std_id std)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
int res = 0;
 
res = zoran_set_norm(zr, std);
@@ -2073,8 +2064,7 @@ static int zoran_s_std(s

[PATCH RFT/RFC v2 34/47] staging: media: zoran: constify codec_name

2020-09-25 Thread Corentin Labbe
The codec_name could be const.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 79783cbb919a..49a1d9e084a8 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -254,9 +254,9 @@ static void avs6eyes_init(struct zoran *zr)
GPIO(zr, 7, mux & 4);   /* MUX S2 */
 }
 
-static char *codecid_to_modulename(u16 codecid)
+static const char *codecid_to_modulename(u16 codecid)
 {
-   char *name = NULL;
+   const char *name = NULL;
 
switch (codecid) {
case CODEC_TYPE_ZR36060:
@@ -1102,7 +1102,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
struct videocodec_master *master_vfe = NULL;
struct videocodec_master *master_codec = NULL;
int card_num;
-   char *codec_name, *vfe_name;
+   const char *codec_name, *vfe_name;
unsigned int nr;
 
nr = zoran_num++;
-- 
2.26.2

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


[PATCH RFT/RFC v2 27/47] staging: media: zoran: convert zoran alloc to devm

2020-09-25 Thread Corentin Labbe
Allocate the zoran structure with devm_ functions permit to simplify
code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 706b040f5baa..fe0c5a7c967c 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1024,7 +1024,6 @@ static void zoran_remove(struct pci_dev *pdev)
 exit_free:
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
-   kfree(zr);
 }
 
 void zoran_vdev_release(struct video_device *vdev)
@@ -1109,7 +1108,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return -ENOENT;
}
 
-   zr = kzalloc(sizeof(*zr), GFP_KERNEL);
+   zr = devm_kzalloc(>dev, sizeof(*zr), GFP_KERNEL);
if (!zr)
return -ENOMEM;
 
@@ -1298,7 +1297,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
 zr_free_mem:
-   kfree(zr);
 
return -ENODEV;
 }
-- 
2.26.2

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


[PATCH RFT/RFC v2 35/47] staging: media: zoran: Add more check for compliance

2020-09-25 Thread Corentin Labbe
The zoran driver miss some sanity checks, and this made v4l compliance
happy.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 60bbc8235cff..5ac832eca501 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1092,6 +1092,11 @@ static int zoran_enum_fmt(struct zoran *zr, struct 
v4l2_fmtdesc *fmt, int flag)
 {
unsigned int num, i;
 
+   if (fmt->index >= ARRAY_SIZE(zoran_formats))
+   return -EINVAL;
+   if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
for (num = i = 0; i < NUM_FORMATS; i++) {
if (zoran_formats[i].flags & flag && num++ == fmt->index) {
strscpy(fmt->description, zoran_formats[i].name,
@@ -1255,6 +1260,12 @@ static int zoran_try_fmt_vid_cap(struct file *file, void 
*__fh,
if (i == NUM_FORMATS)
return -EINVAL;
 
+   fmt->fmt.pix.colorspace = zoran_formats[i].colorspace;
+   if (BUZ_MAX_HEIGHT < (fmt->fmt.pix.height * 2))
+   fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   else
+   fmt->fmt.pix.field = V4L2_FIELD_TOP;
+
bpp = DIV_ROUND_UP(zoran_formats[i].depth, 8);
v4l_bound_align_image(>fmt.pix.width, BUZ_MIN_WIDTH, 
BUZ_MAX_WIDTH, bpp == 2 ? 1 : 2,
>fmt.pix.height, BUZ_MIN_HEIGHT, BUZ_MAX_HEIGHT, 0, 0);
@@ -1283,6 +1294,9 @@ static int zoran_s_fmt_vid_out(struct file *file, void 
*__fh,
return res;
}
 
+   if (!fmt->fmt.pix.height || !fmt->fmt.pix.width)
+   return -EINVAL;
+
settings = zr->jpg_settings;
 
/* we actually need to set 'real' parameters now */
@@ -1872,6 +1886,9 @@ static int zoran_s_selection(struct file *file, void 
*__fh, struct v4l2_selectio
sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   if (!sel->r.width || !sel->r.height)
+   return -EINVAL;
+
if (sel->target != V4L2_SEL_TGT_CROP)
return -EINVAL;
 
-- 
2.26.2

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


[PATCH RFT/RFC v2 37/47] staging: media: zoran: disable output

2020-09-25 Thread Corentin Labbe
Zoran is picky about jpeg data it accepts. At least it seems to not support COM 
and APPn.
So until a way to filter data will be done, disable output.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 ++
 drivers/staging/media/zoran/zoran_driver.c | 20 
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index fed368ba6fd1..dbdb1c4b0515 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -963,6 +963,8 @@ static int zr36057_init(struct zoran *zr)
*zr->video_dev = zoran_template;
zr->video_dev->v4l2_dev = >v4l2_dev;
zr->video_dev->lock = >lock;
+   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
+
strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
/*
 * It's not a mem2mem device, but you can both capture and output from 
one and the same
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index e962fc6c1f9f..43f7c0c02876 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1082,8 +1082,7 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE |
-  V4L2_CAP_VIDEO_OUTPUT;
+   cap->device_caps = zr->video_dev->device_caps;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
@@ -2221,6 +2220,11 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
return res;
 }
 
+/*
+ * Output is disabled temporarily
+ * Zoran is picky about jpeg data it accepts. At least it seems to unsupport 
COM and APPn.
+ * So until a way to filter data will be done, disable output.
+ */
 static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_querycap= zoran_querycap,
.vidioc_s_selection = zoran_s_selection,
@@ -2228,9 +2232,9 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_enum_input  = zoran_enum_input,
.vidioc_g_input = zoran_g_input,
.vidioc_s_input = zoran_s_input,
-   .vidioc_enum_output = zoran_enum_output,
+/* .vidioc_enum_output = zoran_enum_output,
.vidioc_g_output= zoran_g_output,
-   .vidioc_s_output= zoran_s_output,
+   .vidioc_s_output= zoran_s_output,*/
.vidioc_g_fbuf  = zoran_g_fbuf,
.vidioc_s_fbuf  = zoran_s_fbuf,
.vidioc_g_std   = zoran_g_std,
@@ -2244,13 +2248,13 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_streamon= zoran_streamon,
.vidioc_streamoff   = zoran_streamoff,
.vidioc_enum_fmt_vid_cap= zoran_enum_fmt_vid_cap,
-   .vidioc_enum_fmt_vid_out= zoran_enum_fmt_vid_out,
+/* .vidioc_enum_fmt_vid_out= zoran_enum_fmt_vid_out,*/
.vidioc_g_fmt_vid_cap   = zoran_g_fmt_vid_cap,
-   .vidioc_g_fmt_vid_out   = zoran_g_fmt_vid_out,
+/* .vidioc_g_fmt_vid_out   = zoran_g_fmt_vid_out,*/
.vidioc_s_fmt_vid_cap   = zoran_s_fmt_vid_cap,
-   .vidioc_s_fmt_vid_out   = zoran_s_fmt_vid_out,
+/* .vidioc_s_fmt_vid_out   = zoran_s_fmt_vid_out,*/
.vidioc_try_fmt_vid_cap = zoran_try_fmt_vid_cap,
-   .vidioc_try_fmt_vid_out = zoran_try_fmt_vid_out,
+/* .vidioc_try_fmt_vid_out = zoran_try_fmt_vid_out,*/
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
-- 
2.26.2

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


[PATCH RFT/RFC v2 39/47] staging: media: zoran: enable makefile

2020-09-25 Thread Corentin Labbe
This patch enables compilation of the zoran driver.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 25910221b100..965a8b0e6cf2 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_VIDEO_HANTRO)+= hantro/
 obj-$(CONFIG_VIDEO_IPU3_IMGU)  += ipu3/
 obj-$(CONFIG_PHY_ROCKCHIP_DPHY_RX0)+= phy-rockchip-dphy-rx0/
 obj-$(CONFIG_VIDEO_ROCKCHIP_ISP1)  += rkisp1/
+obj-$(CONFIG_VIDEO_ZORAN)  += zoran/
-- 
2.26.2

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


[PATCH RFT/RFC v2 11/47] staging: media: zoran: zoran_device.c: convert pr_x to pci_x

2020-09-25 Thread Corentin Labbe
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 61b4cfccc168..e50153218f72 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -162,7 +162,7 @@ static void dump_guests(struct zoran *zr)
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest[i] = post_office_read(zr, i, 0);
 
-   pr_info("%s: Guests: %*ph\n", ZR_DEVNAME(zr), 8, guest);
+   pci_info(zr->pci_dev, "Guests: %*ph\n", 8, guest);
}
 }
 
@@ -172,7 +172,7 @@ void detect_guest_activity(struct zoran *zr)
ktime_t t0, t1;
 
dump_guests(zr);
-   pr_info("%s: Detecting guests activity, please wait...\n", 
ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Detecting guests activity, please wait...\n");
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest0[i] = guest[i] = post_office_read(zr, i, 0);
 
@@ -198,15 +198,14 @@ void detect_guest_activity(struct zoran *zr)
break;
}
 
-   pr_info("%s: Guests: %*ph\n", ZR_DEVNAME(zr), 8, guest0);
+   pci_info(zr->pci_dev, "Guests: %*ph\n", 8, guest0);
 
if (j == 0) {
-   pr_info("%s: No activity detected.\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "No activity detected.\n");
return;
}
for (i = 0; i < j; i++)
-   pr_info("%s: %6d: %d => 0x%02x\n", ZR_DEVNAME(zr),
-   change[i][0], change[i][1], change[i][2]);
+   pci_info(zr->pci_dev, "%6d: %d => 0x%02x\n", change[i][0], 
change[i][1], change[i][2]);
 }
 
 /*
-- 
2.26.2

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


[PATCH RFT/RFC v2 10/47] staging: media: zoran: convert dprintk debug

2020-09-25 Thread Corentin Labbe
This patch convert dprintk(debug) to pci_dbg.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 30 --
 drivers/staging/media/zoran/zoran_card.h   |  6 -
 drivers/staging/media/zoran/zoran_device.c |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 28 
 4 files changed, 21 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index f2387f4906c0..e9c0dc1c0313 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -203,7 +203,7 @@ void zr36016_write(struct videocodec *codec, u16 reg, u32 
val)
 
 static void dc10_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
/* Pixel clock selection */
GPIO(zr, 4, 0);
@@ -214,12 +214,12 @@ static void dc10_init(struct zoran *zr)
 
 static void dc10plus_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 }
 
 static void buz_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
/* some stuff from Iomega */
pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15);
@@ -229,7 +229,7 @@ static void buz_init(struct zoran *zr)
 
 static void lml33_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
GPIO(zr, 2, 1); // Set Composite input/output
 }
@@ -671,15 +671,11 @@ int zoran_check_jpg_settings(struct zoran *zr,
 {
int err = 0, err0 = 0;
 
-   dprintk(4,
-   KERN_DEBUG
-   "%s: %s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
-   ZR_DEVNAME(zr), __func__, settings->decimation, 
settings->HorDcm,
+   pci_dbg(zr->pci_dev, "%s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
+   __func__, settings->decimation, settings->HorDcm,
settings->VerDcm, settings->TmpDcm);
-   dprintk(4,
-   KERN_DEBUG
-   "%s: %s - x: %d, y: %d, w: %d, y: %d\n",
-   ZR_DEVNAME(zr), __func__, settings->img_x, settings->img_y,
+   pci_dbg(zr->pci_dev, "%s - x: %d, y: %d, w: %d, y: %d\n", __func__,
+   settings->img_x, settings->img_y,
settings->img_width, settings->img_height);
/* Check decimation, set default values for decimation = 1, 2, 4 */
switch (settings->decimation) {
@@ -709,10 +705,7 @@ int zoran_check_jpg_settings(struct zoran *zr,
case 4:
 
if (zr->card.type == DC10_new) {
-   dprintk(1,
-   KERN_DEBUG
-   "%s: %s - HDec by 4 is not supported on the 
DC10\n",
-   ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s - HDec by 4 is not supported 
on the DC10\n", __func__);
err0++;
break;
}
@@ -1157,10 +1150,7 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
pci_err(pdev, "Unknown card, try specifying card=X 
module parameter\n");
goto zr_unreg;
}
-   dprintk(3,
-   KERN_DEBUG
-   "%s: %s() - card %s detected\n",
-   ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
+   pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__, 
zoran_cards[card_num].name);
} else {
card_num = card[nr];
if (card_num >= NUM_CARDS || card_num < 0) {
diff --git a/drivers/staging/media/zoran/zoran_card.h 
b/drivers/staging/media/zoran/zoran_card.h
index 4af8cb91d03a..8e0d634cb30f 100644
--- a/drivers/staging/media/zoran/zoran_card.h
+++ b/drivers/staging/media/zoran/zoran_card.h
@@ -14,12 +14,6 @@
 
 extern int zr36067_debug;
 
-#define dprintk(num, format, args...) \
-   do { \
-   if (zr36067_debug >= num) \
-   printk(format, ##args); \
-   } while (0)
-
 /* Anybody who uses more than four? */
 #define BUZ_MAX 4
 
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 013d44801e68..61b4cfccc168 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -874,7 +874,7 @@ void jpeg_start(struct zoran *zr)
 
set_frame(zr, 1);

[PATCH RFT/RFC v2 26/47] staging: media: zoran: convert irq to pci irq

2020-09-25 Thread Corentin Labbe
This patch convert zoran to pci_irq functions.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 8be7f8f0a020..706b040f5baa 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1015,7 +1015,7 @@ static void zoran_remove(struct pci_dev *pdev)
zoran_set_pci_master(zr, 0);
/* put chip into reset */
btwrite(0, ZR36057_SPGPPCR);
-   free_irq(zr->pci_dev->irq, zr);
+   pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
@@ -1175,8 +1175,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto zr_unreg;
}
 
-   result = request_irq(zr->pci_dev->irq, zoran_irq,
-IRQF_SHARED, ZR_DEVNAME(zr), zr);
+   result = pci_request_irq(pdev, 0, zoran_irq, NULL, zr, ZR_DEVNAME(zr));
if (result < 0) {
if (result == -EINVAL) {
pci_err(pdev, "%s - bad IRQ number or handler\n", 
__func__);
@@ -1292,7 +1291,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zoran_unregister_i2c(zr);
 zr_free_irq:
btwrite(0, ZR36057_SPGPPCR);
-   free_irq(zr->pci_dev->irq, zr);
+   pci_free_irq(zr->pci_dev, 0, zr);
 zr_unmap:
iounmap(zr->zr36057_mem);
 zr_unreg:
-- 
2.26.2

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


[PATCH RFT/RFC v2 21/47] staging: media: zoran: Change zoran_v4l_set_format parameter from zoran_fh to zoran

2020-09-25 Thread Corentin Labbe
We need to get rid of zoran_fh, so let's change function arguments.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 518ba19e1e0a..db85978a2893 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -401,11 +401,9 @@ static void jpg_fbuffer_free(struct zoran_fh *fh)
 /*
  *   V4L Buffer grabbing
  */
-
-static int zoran_v4l_set_format(struct zoran_fh *fh, int width, int height,
+static int zoran_v4l_set_format(struct zoran *zr, int width, int height,
const struct zoran_format *format)
 {
-   struct zoran *zr = fh->zr;
int bpp;
 
/* Check size and format of the grab wanted */
@@ -1671,7 +1669,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
 
map_mode_raw(fh);
 
-   res = zoran_v4l_set_format(fh, fmt->fmt.pix.width, fmt->fmt.pix.height,
+   res = zoran_v4l_set_format(zr, fmt->fmt.pix.width, fmt->fmt.pix.height,
   _formats[i]);
if (res)
return res;
-- 
2.26.2

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


[PATCH RFT/RFC v2 23/47] staging: media: zoran: Use DMA coherent for stat_com

2020-09-25 Thread Corentin Labbe
Instead of using a fragile virt_to_bus, let's use proper DMA coherent
for the stat_com entry.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  2 ++
 drivers/staging/media/zoran/zoran_card.c   | 22 +++---
 drivers/staging/media/zoran/zoran_device.c |  3 +--
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index aa2a8f688a01..8f3faa4eb60f 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -351,6 +351,8 @@ struct zoran {
unsigned long frame_num;
 
wait_queue_head_t test_q;
+
+   dma_addr_t p_sc;
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 5919803a6a5e..9fe2bc2b036a 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -936,11 +936,17 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
zr->video_dev = video_device_alloc();
-   if (!zr->stat_com || !zr->video_dev) {
+   if (!zr->video_dev) {
err = -ENOMEM;
-   goto exit_free;
+   goto exit;
+   }
+   zr->stat_com = dma_alloc_coherent(>pci_dev->dev,
+ BUZ_NUM_STAT_COM * sizeof(u32),
+ >p_sc, GFP_KERNEL);
+   if (!zr->stat_com) {
+   err = -ENOMEM;
+   goto exit_video;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -958,7 +964,7 @@ static int zr36057_init(struct zoran *zr)
zr->video_dev->vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
-   goto exit_free;
+   goto exit_statcom;
video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
@@ -973,9 +979,11 @@ static int zr36057_init(struct zoran *zr)
zr->initialized = 1;
return 0;
 
-exit_free:
-   kfree(zr->stat_com);
+exit_statcom:
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
+exit_video:
kfree(zr->video_dev);
+exit:
return err;
 }
 
@@ -1009,7 +1017,7 @@ static void zoran_remove(struct pci_dev *pdev)
btwrite(0, ZR36057_SPGPPCR);
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
-   kfree(zr->stat_com);
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 627ebda33cc8..0ecb044f8e8f 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -579,8 +579,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
//btor(ZR36057_VFESPFR_VCLKPol, ZR36057_VFESPFR);
 
/* code base address */
-   reg = virt_to_bus(zr->stat_com);
-   btwrite(reg, ZR36057_JCBA);
+   btwrite(zr->p_sc, ZR36057_JCBA);
 
/* FIFO threshold (FIFO is 160. double words) */
/* NOTE: decimal values here */
-- 
2.26.2

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


[PATCH RFT/RFC v2 17/47] staging: media: zoran: move v4l_settings out of zoran_fh

2020-09-25 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the v4l_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  1 -
 drivers/staging/media/zoran/zoran_driver.c | 38 ++
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 97933c550113..a529b49888c6 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -217,7 +217,6 @@ struct zoran_fh {
 
struct zoran_buffer_col buffers;/* buffers' info */
 
-   struct zoran_v4l_settings v4l_settings; /* structure with a lot of 
things to play with */
struct zoran_jpg_settings jpg_settings; /* structure with a lot of 
things to play with */
 };
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 2a00a3a72dad..e60db53c0359 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -432,10 +432,10 @@ static int zoran_v4l_set_format(struct zoran_fh *fh, int 
width, int height,
return -EINVAL;
}
 
-   fh->v4l_settings.width = width;
-   fh->v4l_settings.height = height;
-   fh->v4l_settings.format = format;
-   fh->v4l_settings.bytesperline = bpp * fh->v4l_settings.width;
+   zr->v4l_settings.width = width;
+   zr->v4l_settings.height = height;
+   zr->v4l_settings.format = format;
+   zr->v4l_settings.bytesperline = bpp * zr->v4l_settings.width;
 
return 0;
 }
@@ -489,7 +489,7 @@ static int zoran_v4l_queue_frame(struct zoran_fh *fh, int 
num)
zr->v4l_pend[zr->v4l_pend_head++ & V4L_MASK_FRAME] = 
num;
zr->v4l_buffers.buffer[num].state = BUZ_STATE_PEND;
zr->v4l_buffers.buffer[num].bs.length =
-   fh->v4l_settings.bytesperline *
+   zr->v4l_settings.bytesperline *
zr->v4l_settings.height;
fh->buffers.buffer[num] = zr->v4l_buffers.buffer[num];
break;
@@ -751,8 +751,6 @@ static void zoran_open_init_session(struct zoran_fh *fh)
fh->overlay_settings.format = zr->overlay_settings.format;
fh->overlay_active = ZORAN_FREE;
 
-   /* v4l settings */
-   fh->v4l_settings = zr->v4l_settings;
/* jpg settings */
fh->jpg_settings = zr->jpg_settings;
 
@@ -1205,7 +1203,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
buf->flags |= V4L2_BUF_FLAG_QUEUED;
}
 
-   if (fh->v4l_settings.height <= BUZ_MAX_HEIGHT / 2)
+   if (zr->v4l_settings.height <= BUZ_MAX_HEIGHT / 2)
buf->field = V4L2_FIELD_TOP;
else
buf->field = V4L2_FIELD_INTERLACED;
@@ -1421,14 +1419,13 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh,
if (fh->map_mode != ZORAN_MAP_MODE_RAW)
return zoran_g_fmt_vid_out(file, fh, fmt);
 
-   fmt->fmt.pix.width = fh->v4l_settings.width;
-   fmt->fmt.pix.height = fh->v4l_settings.height;
-   fmt->fmt.pix.sizeimage = fh->v4l_settings.bytesperline *
-   fh->v4l_settings.height;
-   fmt->fmt.pix.pixelformat = fh->v4l_settings.format->fourcc;
-   fmt->fmt.pix.colorspace = fh->v4l_settings.format->colorspace;
-   fmt->fmt.pix.bytesperline = fh->v4l_settings.bytesperline;
-   if (BUZ_MAX_HEIGHT < (fh->v4l_settings.height * 2))
+   fmt->fmt.pix.width = zr->v4l_settings.width;
+   fmt->fmt.pix.height = zr->v4l_settings.height;
+   fmt->fmt.pix.sizeimage = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+   fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc;
+   fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
+   fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
else
fmt->fmt.pix.field = V4L2_FIELD_TOP;
@@ -1698,10 +1695,10 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh,
return res;
 
/* tell the user the results/missing stuff */
-   fmt->fmt.pix.bytesperline = fh->v4l_settings.bytesperline;
-   fmt->fmt.pix.sizeimage = fh->v4l_settings.height * 
fh->v4l_settings.bytesperline;
-   fmt->fmt.pix.colorspace = fh->v4l_settings.format->colorspace;
-   if (BUZ_MAX_HEIGHT < (fh->v4l_settings.height * 2))
+   fmt->f

[PATCH RFT/RFC v2 12/47] staging: media: zoran: remove proc_fs

2020-09-25 Thread Corentin Labbe
The zoran driver give some debug information in procfs, but this is not
the right place.
So let's remove them, we will use debugfs later.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Makefile   |   2 +-
 drivers/staging/media/zoran/zoran.h|   5 -
 drivers/staging/media/zoran/zoran_card.c   |   6 -
 drivers/staging/media/zoran/zoran_device.c |   1 -
 drivers/staging/media/zoran/zoran_driver.c |   1 -
 drivers/staging/media/zoran/zoran_procfs.c | 213 -
 drivers/staging/media/zoran/zoran_procfs.h |  32 
 7 files changed, 1 insertion(+), 259 deletions(-)
 delete mode 100644 drivers/staging/media/zoran/zoran_procfs.c
 delete mode 100644 drivers/staging/media/zoran/zoran_procfs.h

diff --git a/drivers/staging/media/zoran/Makefile 
b/drivers/staging/media/zoran/Makefile
index 21ac29a71458..7023158e3892 100644
--- a/drivers/staging/media/zoran/Makefile
+++ b/drivers/staging/media/zoran/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-zr36067-objs   :=  zoran_procfs.o zoran_device.o \
+zr36067-objs   :=  zoran_device.o \
zoran_driver.o zoran_card.o
 
 obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index eac8e49a080f..1b3eceaead5a 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -346,11 +346,6 @@ struct zoran {
struct zoran_buffer_col jpg_buffers;/* MJPEG buffers' info */
 
/* Additional stuff for testing */
-#ifdef CONFIG_PROC_FS
-   struct proc_dir_entry *zoran_proc;
-#else
-   void *zoran_proc;
-#endif
int testing;
int jpeg_error;
int intr_counter_GIRQ1;
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index e9c0dc1c0313..93a0817a3936 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -38,7 +37,6 @@
 #include "zoran.h"
 #include "zoran_card.h"
 #include "zoran_device.h"
-#include "zoran_procfs.h"
 
 extern const struct zoran_format zoran_formats[];
 
@@ -978,7 +976,6 @@ static int zr36057_init(struct zoran *zr)
encoder_call(zr, video, s_routing, 2, 0, 0);
}
 
-   zr->zoran_proc = NULL;
zr->initialized = 1;
return 0;
 
@@ -1019,7 +1016,6 @@ static void zoran_remove(struct pci_dev *pdev)
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
kfree(zr->stat_com);
-   zoran_proc_cleanup(zr);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
@@ -1280,8 +1276,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (zr36057_init(zr) < 0)
goto zr_detach_vfe;
 
-   zoran_proc_init(zr);
-
return 0;
 
 zr_detach_vfe:
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index e50153218f72..04ba22a915f0 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -17,7 +17,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 21a258b7be13..0d6c58a4161e 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -53,7 +53,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include "zoran.h"
diff --git a/drivers/staging/media/zoran/zoran_procfs.c 
b/drivers/staging/media/zoran/zoran_procfs.c
deleted file mode 100644
index 98f9e0103d83..
--- a/drivers/staging/media/zoran/zoran_procfs.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Zoran zr36057/zr36067 PCI controller driver, for the
- * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
- * Media Labs LML33/LML33R10.
- *
- * This part handles the procFS entries (/proc/ZORAN[%d])
- *
- * Copyright (C) 2000 Serguei Miridonov 
- *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 

[PATCH RFT/RFC v2 03/47] staging: media: zoran: datasheet is no longer available from zoran.com

2020-09-25 Thread Corentin Labbe
Simply remove this broken reference

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 04162be80420..79da964c678b 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -265,9 +265,6 @@ jpeg_codec_reset (struct zoran *zr)
  *   Set the registers for the size we have specified. Don't bother
  *   trying to understand this without the ZR36057 manual in front of
  *   you [AC].
- *
- *   PS: The manual is free for download in .pdf format from
- *   www.zoran.com - nicely done those folks.
  */
 
 static void
-- 
2.26.2

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


[PATCH RFT/RFC v2 22/47] staging: media: zoran: remove overlay

2020-09-25 Thread Corentin Labbe
Supporting overlay is not necessary today, so let's reduce the code size
by removing it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  16 -
 drivers/staging/media/zoran/zoran_card.c   |   6 -
 drivers/staging/media/zoran/zoran_device.c | 143 +
 drivers/staging/media/zoran/zoran_driver.c | 329 +
 4 files changed, 12 insertions(+), 482 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index e9fef23a720c..aa2a8f688a01 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -139,14 +139,6 @@ struct zoran_format {
 #define ZORAN_FORMAT_CAPTURE BIT(2)
 #define ZORAN_FORMAT_PLAYBACK BIT(3)
 
-/* overlay-settings */
-struct zoran_overlay_settings {
-   int is_set;
-   int x, y, width, height;/* position */
-   int clipcount;  /* position and number of clips */
-   const struct zoran_format *format;  /* overlay format */
-};
-
 /* v4l-capture settings */
 struct zoran_v4l_settings {
int width, height, bytesperline;/* capture size */
@@ -211,9 +203,6 @@ struct zoran_fh {
 
enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
 
-   u32 *overlay_mask;  /* overlay mask */
-   enum zoran_lock_activity overlay_active;/* feature currently in use? */
-
struct zoran_buffer_col buffers;/* buffers' info */
 };
 
@@ -294,13 +283,8 @@ struct zoran {
int vbuf_depth;
int vbuf_bytesperline;
 
-   struct zoran_overlay_settings overlay_settings;
-   u32 *overlay_mask;  /* overlay mask */
-   enum zoran_lock_activity overlay_active;/* feature currently in 
use? */
-
wait_queue_head_t v4l_capq;
 
-   int v4l_overlay_active; /* Overlay grab is activated */
int v4l_memgrab_active; /* Memory grab is activated */
 
int v4l_grab_frame; /* Frame number being currently grabbed */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 55315f67b3b9..5919803a6a5e 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -814,13 +814,7 @@ void zoran_open_init_params(struct zoran *zr)
 {
int i;
 
-   /* User must explicitly set a window */
-   zr->overlay_settings.is_set = 0;
-   zr->overlay_mask = NULL;
-   zr->overlay_active = ZORAN_FREE;
-
zr->v4l_memgrab_active = 0;
-   zr->v4l_overlay_active = 0;
zr->v4l_grab_frame = NO_GRAB_ACTIVE;
zr->v4l_grab_seq = 0;
zr->v4l_settings.width = 192;
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 139cfc683b98..627ebda33cc8 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -300,7 +300,6 @@ static void zr36057_set_vfe(struct zoran *zr, int 
video_width, int video_height,
unsigned int Wa, We, Ha, He;
unsigned int X, Y, HorDcm, VerDcm;
u32 reg;
-   unsigned int mask_line_size;
 
tvn = zr->timing;
 
@@ -395,143 +394,9 @@ static void zr36057_set_vfe(struct zoran *zr, int 
video_width, int video_height,
reg |= ZR36057_VDCR_Triton;
btwrite(reg, ZR36057_VDCR);
 
-   /* (Ronald) don't write this if overlay_mask = NULL */
-   if (zr->overlay_mask) {
-   /* Write overlay clipping mask data, but don't enable overlay 
clipping */
-   /* RJ: since this makes only sense on the screen, we use
-* zr->overlay_settings.width instead of video_width */
-
-   mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
-   reg = virt_to_bus(zr->overlay_mask);
-   btwrite(reg, ZR36057_MMTR);
-   reg = virt_to_bus(zr->overlay_mask + mask_line_size);
-   btwrite(reg, ZR36057_MMBR);
-   reg =
-   mask_line_size - (zr->overlay_settings.width +
- 31) / 32;
-   if (DispMode == 0)
-   reg += mask_line_size;
-   reg <<= ZR36057_OCR_MaskStride;
-   btwrite(reg, ZR36057_OCR);
-   }
-
zr36057_adjust_vfe(zr, zr->codec_mode);
 }
 
-/*
- * Switch overlay on or off
- */
-
-void zr36057_overlay(struct zoran *zr, int on)
-{
-   u32 reg;
-
-   if (on) {
-   /* do the necessary settings ... */
-   btand(~ZR36057_VDCR_VidEn, ZR36057_VDCR);   /* switch it 
off first */
-
-   zr36057_set_vfe(zr,
-   zr->overlay_settings.width,
-   zr->overlay_settings.height,
-   zr->overlay_settings.format);
-
-   /* Start and length of each line MUST 

[PATCH RFT/RFC v2 13/47] staging: media: zoran: use VFL_TYPE_VIDEO

2020-09-25 Thread Corentin Labbe
The VFL_TYPE_GRABBER type was removed, so let's use the new type.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 93a0817a3936..55315f67b3b9 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -962,7 +962,7 @@ static int zr36057_init(struct zoran *zr)
 * another day.
 */
zr->video_dev->vfl_dir = VFL_DIR_M2M;
-   err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, 
video_nr[zr->id]);
+   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
goto exit_free;
video_set_drvdata(zr->video_dev, zr);
-- 
2.26.2

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


[PATCH RFT/RFC v2 16/47] staging: media: zoran: move buffer_size out of zoran_fh

2020-09-25 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the buffer_size directly in the
zoran structure.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  3 +-
 drivers/staging/media/zoran/zoran_device.c |  3 +-
 drivers/staging/media/zoran/zoran_driver.c | 62 +++---
 3 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 1b3eceaead5a..97933c550113 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -195,7 +195,7 @@ enum zoran_lock_activity {
 /* buffer collections */
 struct zoran_buffer_col {
enum zoran_lock_activity active;/* feature currently in use? */
-   unsigned int num_buffers, buffer_size;
+   unsigned int num_buffers;
struct zoran_buffer buffer[MAX_FRAME];  /* buffers */
u8 allocated;   /* Flag if buffers are allocated */
u8 need_contiguous; /* Flag if contiguous buffers are needed */
@@ -292,6 +292,7 @@ struct zoran {
v4l2_std_id norm;
 
/* Current buffer params */
+   unsigned int buffer_size;
void *vbuf_base;
int vbuf_height, vbuf_width;
int vbuf_depth;
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index dfc2551f2d71..672b8d927e0f 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -885,8 +885,7 @@ void jpeg_start(struct zoran *zr)
 void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)
 {
struct vfe_settings cap;
-   int field_size =
-   zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff;
+   int field_size = zr->buffer_size / zr->jpg_settings.field_per_buff;
 
zr->codec_mode = mode;
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index e74fd6a62606..2a00a3a72dad 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -178,15 +178,18 @@ static void jpg_fbuffer_free(struct zoran_fh *fh);
 /* Set mapping mode */
 static void map_mode_raw(struct zoran_fh *fh)
 {
+   struct zoran *zr = fh->zr;
fh->map_mode = ZORAN_MAP_MODE_RAW;
-   fh->buffers.buffer_size = v4l_bufsize;
+   zr->buffer_size = v4l_bufsize;
fh->buffers.num_buffers = v4l_nbufs;
 }
 
 static void map_mode_jpg(struct zoran_fh *fh, int play)
 {
+   struct zoran *zr = fh->zr;
+
fh->map_mode = play ? ZORAN_MAP_MODE_JPG_PLAY : ZORAN_MAP_MODE_JPG_REC;
-   fh->buffers.buffer_size = jpg_bufsize;
+   zr->buffer_size = jpg_bufsize;
fh->buffers.num_buffers = jpg_nbufs;
 }
 
@@ -212,7 +215,7 @@ static int v4l_fbuffer_alloc(struct zoran_fh *fh)
pci_warn(zr->pci_dev, "%s - buffer %d already 
allocated!?\n", __func__, i);
 
//udelay(20);
-   mem = kmalloc(fh->buffers.buffer_size, GFP_KERNEL | 
__GFP_NOWARN);
+   mem = kmalloc(zr->buffer_size, GFP_KERNEL | __GFP_NOWARN);
if (!mem) {
pci_err(zr->pci_dev, "%s - kmalloc for V4L buf %d 
failed\n", __func__, i);
v4l_fbuffer_free(fh);
@@ -221,7 +224,7 @@ static int v4l_fbuffer_alloc(struct zoran_fh *fh)
fh->buffers.buffer[i].v4l.fbuffer = mem;
fh->buffers.buffer[i].v4l.fbuffer_phys = virt_to_phys(mem);
fh->buffers.buffer[i].v4l.fbuffer_bus = virt_to_bus(mem);
-   for (off = 0; off < fh->buffers.buffer_size;
+   for (off = 0; off < zr->buffer_size;
 off += PAGE_SIZE)
SetPageReserved(virt_to_page(mem + off));
pci_info(zr->pci_dev, "%s - V4L frame %d mem %p (bus: 
0x%llx)\n", __func__, i, mem,
@@ -247,7 +250,7 @@ static void v4l_fbuffer_free(struct zoran_fh *fh)
continue;
 
mem = fh->buffers.buffer[i].v4l.fbuffer;
-   for (off = 0; off < fh->buffers.buffer_size;
+   for (off = 0; off < zr->buffer_size;
 off += PAGE_SIZE)
ClearPageReserved(virt_to_page(mem + off));
kfree(fh->buffers.buffer[i].v4l.fbuffer);
@@ -307,7 +310,7 @@ static int jpg_fbuffer_alloc(struct zoran_fh *fh)
fh->buffers.buffer[i].jpg.frag_tab_bus = virt_to_bus(mem);
 
if (fh->buffers.need_contiguous) {
-   mem = kmalloc(fh->buffers.buffer_size, GFP_KERNEL);
+   mem = kmalloc(zr->buffer_size, GFP_KERNEL);
if (!mem) {
pci_err(zr->pci_dev, "%s - kmalloc failed for 
buffer %d\n", __func__, i)

[PATCH RFT/RFC v2 08/47] staging: media: zoran: convert dprintk warn

2020-09-25 Thread Corentin Labbe
This patch convert dprintk(warn) to pci_warn.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 18 --
 drivers/staging/media/zoran/zoran_device.c | 13 +++---
 drivers/staging/media/zoran/zoran_driver.c | 29 +-
 3 files changed, 14 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 27a79fffb01d..d0b93141df5b 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -938,19 +938,14 @@ static int zr36057_init(struct zoran *zr)
zr->timing = zr->card.tvn[2];
}
if (!zr->timing) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: %s - default TV standard not supported by 
hardware. PAL will be used.\n",
-   ZR_DEVNAME(zr), __func__);
+   pci_warn(zr->pci_dev, "%s - default TV standard not supported 
by hardware. PAL will be used.\n", __func__);
zr->norm = V4L2_STD_PAL;
zr->timing = zr->card.tvn[0];
}
 
if (default_input > zr->card.inputs - 1) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: default_input value %d out of range (0-%d)\n",
-   ZR_DEVNAME(zr), default_input, zr->card.inputs - 1);
+   pci_warn(zr->pci_dev, "default_input value %d out of range 
(0-%d)\n",
+default_input, zr->card.inputs - 1);
default_input = 0;
}
zr->input = default_input;
@@ -1378,11 +1373,8 @@ static int __init zoran_init(void)
}
 
/* some mainboards might not do PCI-PCI data transfer well */
-   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK)) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: chipset does not support reliable PCI-PCI DMA\n", 
ZORAN_NAME);
-   }
+   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
+   pr_warn("%s: chipset does not support reliable PCI-PCI DMA\n", 
ZORAN_NAME);
 
res = pci_register_driver(_driver);
if (res) {
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 806c7285a5e3..f090ee92f0c8 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -547,10 +547,7 @@ void zr36057_set_memgrab(struct zoran *zr, int mode)
 * will be stuck at 1 until capturing is turned back on.
 */
if (btread(ZR36057_VSSFGR) & ZR36057_VSSFGR_SnapShot)
-   dprintk(1,
-   KERN_WARNING
-   "%s: zr36057_set_memgrab(1) with SnapShot 
on!?\n",
-   ZR_DEVNAME(zr));
+   pci_warn(zr->pci_dev, "zr36057_set_memgrab(1) with 
SnapShot on!?\n");
 
/* switch on VSync interrupts */
btwrite(IRQ_MASK, ZR36057_ISR); // Clear Interrupts
@@ -1300,10 +1297,7 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
if (zr->v4l_memgrab_active) {
/* A lot more checks should be here ... */
if ((btread(ZR36057_VSSFGR) & 
ZR36057_VSSFGR_SnapShot) == 0)
-   dprintk(1,
-   KERN_WARNING
-   "%s: BuzIRQ with SnapShot off 
???\n",
-   ZR_DEVNAME(zr));
+   pci_warn(zr->pci_dev, "BuzIRQ with 
SnapShot off ???\n");
 
if (zr->v4l_grab_frame != NO_GRAB_ACTIVE) {
/* There is a grab on a frame going on, 
check if it has finished */
@@ -1422,8 +1416,7 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
 
count++;
if (count > 10) {
-   dprintk(2, KERN_WARNING "%s: irq loop %d\n",
-   ZR_DEVNAME(zr), count);
+   pci_warn(zr->pci_dev, "irq loop %d\n", count);
if (count > 20) {
btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
pci_err(zr->pci_dev, "IRQ lockup, cleared int 
mask\n");
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index f23e9c063919..aed2ac82bfee 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/

[PATCH RFT/RFC v2 09/47] staging: media: zoran: convert dprintk info to pci_info

2020-09-25 Thread Corentin Labbe
This patch convert dprintk(info) to pci_info (or pci_dbg if the message
is not important).

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 46 +++---
 drivers/staging/media/zoran/zoran_device.c | 27 -
 drivers/staging/media/zoran/zoran_driver.c | 34 ++--
 3 files changed, 36 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index d0b93141df5b..f2387f4906c0 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -892,9 +892,9 @@ static void test_interrupts(struct zoran *zr)
btwrite(0, ZR36057_ICR);
btwrite(0x7800, ZR36057_ISR);
zr->testing = 0;
-   dprintk(5, KERN_INFO "%s: Testing interrupts...\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Testing interrupts...\n");
if (timeout)
-   dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
+   pci_info(zr->pci_dev, ": time spent: %d\n", 1 * HZ - timeout);
if (zr36067_debug > 1)
print_interrupts(zr);
btwrite(icr, ZR36057_ICR);
@@ -904,10 +904,7 @@ static int zr36057_init(struct zoran *zr)
 {
int j, err;
 
-   dprintk(1,
-   KERN_INFO
-   "%s: %s - initializing card[%d], zr=%p\n",
-   ZR_DEVNAME(zr), __func__, zr->id, zr);
+   pci_info(zr->pci_dev, "initializing card[%d]\n", zr->id);
 
/* default setup of all parameters which will persist between opens */
zr->user = 0;
@@ -1140,18 +1137,12 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto zr_unreg;
zr->revision = zr->pci_dev->revision;
 
-   dprintk(1,
-   KERN_INFO
-   "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
-   ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
-   zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
-   if (zr->revision >= 2) {
-   dprintk(1,
-   KERN_INFO
-   "%s: Subsystem vendor=0x%04x id=0x%04x\n",
-   ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
-   zr->pci_dev->subsystem_device);
-   }
+   pci_info(zr->pci_dev, "Zoran ZR360%c7 (rev %d), irq: %d, memory: 
0x%08llx\n",
+zr->revision < 2 ? '5' : '6', zr->revision,
+zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 
0));
+   if (zr->revision >= 2)
+   pci_info(zr->pci_dev, "Subsystem vendor=0x%04x id=0x%04x\n",
+zr->pci_dev->subsystem_vendor, 
zr->pci_dev->subsystem_device);
 
/* Use auto-detected card type? */
if (card[nr] == -1) {
@@ -1215,14 +1206,13 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 );
need_latency = zr->revision > 1 ? 32 : 48;
if (latency != need_latency) {
-   dprintk(2, KERN_INFO "%s: Changing PCI latency from %d to %d\n",
-   ZR_DEVNAME(zr), latency, need_latency);
+   pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n", 
latency, need_latency);
pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, 
need_latency);
}
 
zr36057_restart(zr);
/* i2c */
-   dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Initializing i2c bus...\n");
 
if (zoran_register_i2c(zr) < 0) {
pci_err(pdev, "%s - can't initialize i2c bus\n", __func__);
@@ -1238,7 +1228,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
  zr->card.i2c_encoder, 0,
  zr->card.addrs_encoder);
 
-   dprintk(2, KERN_INFO "%s: Initializing videocodec bus...\n", 
ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Initializing videocodec bus...\n");
 
if (zr->card.video_codec) {
codec_name = codecid_to_modulename(zr->card.video_codec);
@@ -1294,9 +1284,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
/* take care of Natoma chipset and a revision 1 zr36057 */
if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
zr->jpg_buffers.need_contiguous = 1;
-   dprintk(1, KERN_INFO
-   "%s: ZR36057/Natoma bug, max. buffer size is 

[PATCH RFT/RFC 23/49] staging: media: zoran: remove overlay

2020-09-21 Thread Corentin Labbe
Supporting overlay is not necessary today, so let's reduce the code size
by removing it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  16 -
 drivers/staging/media/zoran/zoran_card.c   |   6 -
 drivers/staging/media/zoran/zoran_device.c | 143 +
 drivers/staging/media/zoran/zoran_driver.c | 337 +
 4 files changed, 12 insertions(+), 490 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index e9fef23a720c..aa2a8f688a01 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -139,14 +139,6 @@ struct zoran_format {
 #define ZORAN_FORMAT_CAPTURE BIT(2)
 #define ZORAN_FORMAT_PLAYBACK BIT(3)
 
-/* overlay-settings */
-struct zoran_overlay_settings {
-   int is_set;
-   int x, y, width, height;/* position */
-   int clipcount;  /* position and number of clips */
-   const struct zoran_format *format;  /* overlay format */
-};
-
 /* v4l-capture settings */
 struct zoran_v4l_settings {
int width, height, bytesperline;/* capture size */
@@ -211,9 +203,6 @@ struct zoran_fh {
 
enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
 
-   u32 *overlay_mask;  /* overlay mask */
-   enum zoran_lock_activity overlay_active;/* feature currently in use? */
-
struct zoran_buffer_col buffers;/* buffers' info */
 };
 
@@ -294,13 +283,8 @@ struct zoran {
int vbuf_depth;
int vbuf_bytesperline;
 
-   struct zoran_overlay_settings overlay_settings;
-   u32 *overlay_mask;  /* overlay mask */
-   enum zoran_lock_activity overlay_active;/* feature currently in 
use? */
-
wait_queue_head_t v4l_capq;
 
-   int v4l_overlay_active; /* Overlay grab is activated */
int v4l_memgrab_active; /* Memory grab is activated */
 
int v4l_grab_frame; /* Frame number being currently grabbed */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 34841c12c224..3a7895be3341 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -812,13 +812,7 @@ void zoran_open_init_params(struct zoran *zr)
 {
int i;
 
-   /* User must explicitly set a window */
-   zr->overlay_settings.is_set = 0;
-   zr->overlay_mask = NULL;
-   zr->overlay_active = ZORAN_FREE;
-
zr->v4l_memgrab_active = 0;
-   zr->v4l_overlay_active = 0;
zr->v4l_grab_frame = NO_GRAB_ACTIVE;
zr->v4l_grab_seq = 0;
zr->v4l_settings.width = 192;
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index e81316ac6521..e3104b534471 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -300,7 +300,6 @@ static void zr36057_set_vfe(struct zoran *zr, int 
video_width, int video_height,
unsigned int Wa, We, Ha, He;
unsigned int X, Y, HorDcm, VerDcm;
u32 reg;
-   unsigned int mask_line_size;
 
tvn = zr->timing;
 
@@ -395,143 +394,9 @@ static void zr36057_set_vfe(struct zoran *zr, int 
video_width, int video_height,
reg |= ZR36057_VDCR_Triton;
btwrite(reg, ZR36057_VDCR);
 
-   /* (Ronald) don't write this if overlay_mask = NULL */
-   if (zr->overlay_mask) {
-   /* Write overlay clipping mask data, but don't enable overlay 
clipping */
-   /* RJ: since this makes only sense on the screen, we use
-* zr->overlay_settings.width instead of video_width */
-
-   mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
-   reg = virt_to_bus(zr->overlay_mask);
-   btwrite(reg, ZR36057_MMTR);
-   reg = virt_to_bus(zr->overlay_mask + mask_line_size);
-   btwrite(reg, ZR36057_MMBR);
-   reg =
-   mask_line_size - (zr->overlay_settings.width +
- 31) / 32;
-   if (DispMode == 0)
-   reg += mask_line_size;
-   reg <<= ZR36057_OCR_MaskStride;
-   btwrite(reg, ZR36057_OCR);
-   }
-
zr36057_adjust_vfe(zr, zr->codec_mode);
 }
 
-/*
- * Switch overlay on or off
- */
-
-void zr36057_overlay(struct zoran *zr, int on)
-{
-   u32 reg;
-
-   if (on) {
-   /* do the necessary settings ... */
-   btand(~ZR36057_VDCR_VidEn, ZR36057_VDCR);   /* switch it 
off first */
-
-   zr36057_set_vfe(zr,
-   zr->overlay_settings.width,
-   zr->overlay_settings.height,
-   zr->overlay_settings.format);
-
-   /* Start and length of each line MUST 

[PATCH RFT/RFC 48/49] staging: media: zoran: convert to vb2

2020-09-21 Thread Corentin Labbe
This is it! the ultimate last step, the vb2 conversion.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Kconfig|2 +-
 drivers/staging/media/zoran/zoran.h|   83 +-
 drivers/staging/media/zoran/zoran_card.c   |   45 +-
 drivers/staging/media/zoran/zoran_device.c |  488 ++-
 drivers/staging/media/zoran/zoran_driver.c | 1453 +---
 5 files changed, 137 insertions(+), 1934 deletions(-)

diff --git a/drivers/staging/media/zoran/Kconfig 
b/drivers/staging/media/zoran/Kconfig
index ddf38a931c01..492507030276 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -1,6 +1,6 @@
 config VIDEO_ZORAN
tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)"
-   depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 && VIRT_TO_BUS
+   depends on PCI && I2C_ALGOBIT && VIDEO_V4L2
depends on !ALPHA
select VIDEOBUF2_DMA_CONTIG
help
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index fd27d1968e60..372fadfd9a01 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -20,7 +20,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -29,13 +28,6 @@
 #define ZR_NORM_NTSC 1
 #define ZR_NORM_SECAM 2
 
-struct zoran_sync {
-   unsigned long frame;/* number of buffer that has been free'd */
-   unsigned long length;   /* number of code bytes in buffer (capture 
only) */
-   unsigned long seq;  /* frame sequence number */
-   u64 ts; /* timestamp */
-};
-
 struct zr_buffer {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer  vbuf;
@@ -111,18 +103,10 @@ enum zoran_codec_mode {
BUZ_MODE_STILL_DECOMPRESS   /* still frame conversion */
 };
 
-enum zoran_buffer_state {
-   BUZ_STATE_USER, /* buffer is owned by application */
-   BUZ_STATE_PEND, /* buffer is queued in pend[] ready to feed to 
I/O */
-   BUZ_STATE_DMA,  /* buffer is queued in dma[] for I/O */
-   BUZ_STATE_DONE  /* buffer is ready to return to application */
-};
-
 enum zoran_map_mode {
ZORAN_MAP_MODE_NONE,
ZORAN_MAP_MODE_RAW,
ZORAN_MAP_MODE_JPG_REC,
-#define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
ZORAN_MAP_MODE_JPG_PLAY,
 };
 
@@ -174,45 +158,6 @@ struct zoran_jpg_settings {
struct v4l2_jpegcompression jpg_comp;   /* JPEG-specific capture 
settings */
 };
 
-struct zoran_fh;
-
-struct zoran_mapping {
-   struct zoran_fh *fh;
-   atomic_t count;
-};
-
-struct zoran_buffer {
-   struct zoran_mapping *map;
-   enum zoran_buffer_state state;  /* state: unused/pending/dma/done */
-   struct zoran_sync bs;   /* DONE: info to return to application 
*/
-   union {
-   struct {
-   __le32 *frag_tab;   /* addresses of frag table */
-   u32 frag_tab_bus;   /* same value cached to save 
time in ISR */
-   } jpg;
-   struct {
-   char *fbuffer;  /* virtual address of frame 
buffer */
-   unsigned long fbuffer_phys;/* physical address of frame 
buffer */
-   unsigned long fbuffer_bus;/* bus address of frame 
buffer */
-   } v4l;
-   };
-};
-
-enum zoran_lock_activity {
-   ZORAN_FREE, /* free for use */
-   ZORAN_ACTIVE,   /* active but unlocked */
-   ZORAN_LOCKED,   /* locked */
-};
-
-/* buffer collections */
-struct zoran_buffer_col {
-   enum zoran_lock_activity active;/* feature currently in use? */
-   unsigned int num_buffers;
-   struct zoran_buffer buffer[MAX_FRAME];  /* buffers */
-   u8 allocated;   /* Flag if buffers are allocated */
-   u8 need_contiguous; /* Flag if contiguous buffers are needed */
-   /* only applies to jpg buffers, raw buffers are always contiguous */
-};
 
 struct zoran;
 
@@ -220,10 +165,6 @@ struct zoran;
 struct zoran_fh {
struct v4l2_fh fh;
struct zoran *zr;
-
-   enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
-
-   struct zoran_buffer_col buffers;/* buffers' info */
 };
 
 struct card_info {
@@ -281,7 +222,6 @@ struct zoran {
struct mutex lock;  /* file ops serialize lock */
 
u8 initialized; /* flag if zoran has been correctly initialized 
*/
-   int user;   /* number of current users */
struct card_info card;
const struct tvnorm *timing;
 
@@ -300,28 +240,12 @@ struct zoran {
/* Current buffer params */
unsigned int buffer_size;
 
-   wait_queue_head_t v4l_capq;
-
-   int v4l_memgrab_active; /* Memory grab is activated */
-
-   int v4l_grab_

[PATCH RFT/RFC 28/49] staging: media: zoran: convert zoran alloc to devm

2020-09-21 Thread Corentin Labbe
Allocate the zoran structure with devm_ functions permit to simplify
code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index fe4d34e388b4..62e63804ae14 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1017,7 +1017,6 @@ static void zoran_remove(struct pci_dev *pdev)
 exit_free:
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
-   kfree(zr);
 }
 
 void zoran_vdev_release(struct video_device *vdev)
@@ -1101,7 +1100,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return -ENOENT;
}
 
-   zr = kzalloc(sizeof(*zr), GFP_KERNEL);
+   zr = devm_kzalloc(>dev, sizeof(*zr), GFP_KERNEL);
if (!zr)
return -ENOMEM;
 
@@ -1287,7 +1286,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
 zr_free_mem:
-   kfree(zr);
 
return -ENODEV;
 }
-- 
2.26.2

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


[PATCH RFT/RFC 38/49] staging: media: zoran: Add vb_queue

2020-09-21 Thread Corentin Labbe
This patchs adds a vb_queue without using it.
This reduce the final VB2 conversion patch.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Kconfig|   1 +
 drivers/staging/media/zoran/zoran.h|  30 +++
 drivers/staging/media/zoran/zoran_card.c   |   7 +
 drivers/staging/media/zoran/zoran_driver.c | 233 +
 4 files changed, 271 insertions(+)

diff --git a/drivers/staging/media/zoran/Kconfig 
b/drivers/staging/media/zoran/Kconfig
index 34a18135ede0..ddf38a931c01 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -2,6 +2,7 @@ config VIDEO_ZORAN
tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)"
depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 && VIRT_TO_BUS
depends on !ALPHA
+   select VIDEOBUF2_DMA_CONTIG
help
  Say Y for support for MJPEG capture cards based on the Zoran
  36057/36067 PCI controller chipset. This includes the Iomega
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 727ba67afd56..294e52d78e1b 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -21,6 +21,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #define ZR_NORM_PAL 0
 #define ZR_NORM_NTSC 1
@@ -33,6 +36,18 @@ struct zoran_sync {
u64 ts; /* timestamp */
 };
 
+struct zr_buffer {
+   /* common v4l buffer stuff -- must be first */
+   struct vb2_v4l2_buffer  vbuf;
+   struct list_headqueue;
+};
+
+static inline struct zr_buffer *vb2_to_zr_buffer(struct vb2_buffer *vb)
+{
+   struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+
+   return container_of(vbuf, struct zr_buffer, vbuf);
+}
 
 #define ZORAN_NAME"ZORAN"  /* name of the device */
 
@@ -104,6 +119,7 @@ enum zoran_buffer_state {
 };
 
 enum zoran_map_mode {
+   ZORAN_MAP_MODE_NONE,
ZORAN_MAP_MODE_RAW,
ZORAN_MAP_MODE_JPG_REC,
 #define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
@@ -250,6 +266,7 @@ struct zoran {
struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler hdl;
struct video_device *video_dev;
+   struct vb2_queue vq;
 
struct i2c_adapter i2c_adapter; /* */
struct i2c_algo_bit_data i2c_algo;  /* */
@@ -320,6 +337,7 @@ struct zoran {
unsigned long jpg_err_seq;  /* last seq_num before error */
unsigned long jpg_err_shift;
unsigned long jpg_queued_num;   /* count of frames queued since 
grab/play started */
+   unsigned long vbseq;
 
/* zr36057's code buffer table */
__le32 *stat_com;   /* stat_com[i] is indexed by 
dma_head/tail & BUZ_MASK_STAT_COM */
@@ -350,15 +368,23 @@ struct zoran {
int num_errors;
int JPEG_max_missed;
int JPEG_min_missed;
+   unsigned int prepared;
+   unsigned int queued;
 
u32 last_isr;
unsigned long frame_num;
+   int running;
+   int buf_in_reserve;
 
wait_queue_head_t test_q;
 
dma_addr_t p_sc;
__le32 *stat_comb;
dma_addr_t p_scb;
+   enum zoran_map_mode map_mode;
+   struct list_head queued_bufs;
+   spinlock_t queued_bufs_lock; /* Protects queued_bufs */
+   struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2];
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
@@ -376,3 +402,7 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 #define btaor(dat, mask, adr) btwrite((dat) | ((mask) & btread(adr)), adr)
 
 #endif
+
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+void zoran_queue_exit(struct zoran *zr);
+int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index d956bd45194f..93318ae1803a 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -961,6 +961,9 @@ static int zr36057_init(struct zoran *zr)
 * another day.
 */
zr->video_dev->vfl_dir = VFL_DIR_M2M;
+
+   zoran_queue_init(zr, >vq);
+
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
goto exit_statcomb;
@@ -996,6 +999,8 @@ static void zoran_remove(struct pci_dev *pdev)
if (!zr->initialized)
goto exit_free;
 
+   zoran_queue_exit(zr);
+
/* unregister videocodec bus */
if (zr->codec)
videocodec_detach(zr->codec);
@@ -1270,6 +1275,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (zr36057_init(zr) < 0)
goto zr_detach_vfe;
 
+   zr->map_mode = ZORAN_MAP_MODE_RAW;
+
return 0;
 
 zr_detach_vfe:
diff --git a/drivers/staging/media/zoran/zoran_driver.c 

[PATCH RFT/RFC 43/49] staging: media: zoran: add vidioc_g_parm

2020-09-21 Thread Corentin Labbe
Adding vidioc_g_parm made v4l compliance happy.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 0b4bfc184b57..46bf8b32d57a 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -2120,6 +2120,14 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
return res;
 }
 
+static int zoran_g_parm(struct file *file, void *priv, struct v4l2_streamparm 
*parm)
+{
+   if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
+   return 0;
+}
+
 /*
  * Output is disabled temporarily
  * Zoran is picky about jpeg data it accepts. At least it seems to unsupport 
COM and APPn.
@@ -2127,6 +2135,7 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
  */
 static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_querycap= zoran_querycap,
+   .vidioc_g_parm  = zoran_g_parm,
.vidioc_s_selection = zoran_s_selection,
.vidioc_g_selection = zoran_g_selection,
.vidioc_enum_input  = zoran_enum_input,
-- 
2.26.2

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


[PATCH RFT/RFC 42/49] staging: media: zoran: remove framebuffer support

2020-09-21 Thread Corentin Labbe
The framebuffer support is obsolete, so let's reduce code size.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  4 -
 drivers/staging/media/zoran/zoran_card.c   |  6 --
 drivers/staging/media/zoran/zoran_driver.c | 85 --
 3 files changed, 95 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 294e52d78e1b..0246635e0eac 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -299,10 +299,6 @@ struct zoran {
 
/* Current buffer params */
unsigned int buffer_size;
-   void *vbuf_base;
-   int vbuf_height, vbuf_width;
-   int vbuf_depth;
-   int vbuf_bytesperline;
 
wait_queue_head_t v4l_capq;
 
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index ab16a70a7451..530dd326ad94 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -895,12 +895,6 @@ static int zr36057_init(struct zoran *zr)
zr->jpg_buffers.allocated = 0;
zr->v4l_buffers.allocated = 0;
 
-   zr->vbuf_base = (void *)vidmem;
-   zr->vbuf_width = 0;
-   zr->vbuf_height = 0;
-   zr->vbuf_depth = 0;
-   zr->vbuf_bytesperline = 0;
-
/* Avoid nonsense settings from user for default input/norm */
if (default_norm < 0 || default_norm > 2)
default_norm = 0;
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 1efec2edd72f..0b4bfc184b57 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -881,48 +881,6 @@ static int zoran_close(struct file *file)
return 0;
 }
 
-static int setup_fbuffer(struct zoran_fh *fh, void *base, const struct 
zoran_format *fmt,
-int width, int height, int bytesperline)
-{
-   struct zoran *zr = fh->zr;
-
-   /* (Ronald) v4l/v4l2 guidelines */
-   if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
-   return -EPERM;
-
-   /*
-* Don't allow frame buffer overlay if PCI or AGP is buggy, or on
-  ALi Magik (that needs very low latency while the card needs a
-  higher value always)
-*/
-
-   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
-   return -ENXIO;
-
-   /* we need a bytesperline value, even if not given */
-   if (!bytesperline)
-   bytesperline = width * ((fmt->depth + 7) & ~7) / 8;
-
-   if (height <= 0 || width <= 0 || bytesperline <= 0) {
-   pci_err(zr->pci_dev, "%s - invalid height/width/bpl value 
(%d|%d|%d)\n",
-   __func__, width, height, bytesperline);
-   return -EINVAL;
-   }
-   if (bytesperline & 3) {
-   pci_err(zr->pci_dev, "%s - bytesperline (%d) must be 4-byte 
aligned\n",
-   __func__, bytesperline);
-   return -EINVAL;
-   }
-
-   zr->vbuf_base = (void *)((unsigned long)base & ~3);
-   zr->vbuf_height = height;
-   zr->vbuf_width = width;
-   zr->vbuf_depth = fmt->depth;
-   zr->vbuf_bytesperline = bytesperline;
-
-   return 0;
-}
-
 /* get the status of a buffer in the clients buffer queue */
 static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
struct v4l2_buffer *buf, int num)
@@ -1388,47 +1346,6 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
return res;
 }
 
-static int zoran_g_fbuf(struct file *file, void *__fh,
-   struct v4l2_framebuffer *fb)
-{
-   struct zoran *zr = video_drvdata(file);
-
-   memset(fb, 0, sizeof(*fb));
-   fb->base = zr->vbuf_base;
-   fb->fmt.width = zr->vbuf_width;
-   fb->fmt.height = zr->vbuf_height;
-   fb->fmt.bytesperline = zr->vbuf_bytesperline;
-   fb->fmt.colorspace = V4L2_COLORSPACE_SRGB;
-   fb->fmt.field = V4L2_FIELD_INTERLACED;
-   fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
-
-   return 0;
-}
-
-static int zoran_s_fbuf(struct file *file, void *__fh,
-   const struct v4l2_framebuffer *fb)
-{
-   struct zoran *zr = video_drvdata(file);
-   struct zoran_fh *fh = __fh;
-   int i, res = 0;
-   __le32 printformat = __cpu_to_le32(fb->fmt.pixelformat);
-
-   for (i = 0; i < NUM_FORMATS; i++)
-   if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
-   break;
-   if (i == NUM_FORMATS) {
-   pci_err(zr->pci_dev, "VIDIOC_S_FBUF - format=0x%x (%4.4s) not 
allowed\n",
-   fb->fmt.pixelformat,
-   (ch

[PATCH RFT/RFC 39/49] staging: media: zoran: disable output

2020-09-21 Thread Corentin Labbe
Zoran is picky about jpeg data it accepts. At least it seems to not support COM 
and APPn.
So until a way to filter data will be done, disable output.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 ++
 drivers/staging/media/zoran/zoran_driver.c | 20 
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 93318ae1803a..864196e7acae 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -954,6 +954,8 @@ static int zr36057_init(struct zoran *zr)
*zr->video_dev = zoran_template;
zr->video_dev->v4l2_dev = >v4l2_dev;
zr->video_dev->lock = >lock;
+   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
+
strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
/*
 * It's not a mem2mem device, but you can both capture and output from 
one and the same
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 2c1e70cf2f0c..1efec2edd72f 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1082,8 +1082,7 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE |
-  V4L2_CAP_VIDEO_OUTPUT;
+   cap->device_caps = zr->video_dev->device_caps;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
@@ -2204,6 +2203,11 @@ static int zoran_mmap(struct file *file, struct 
vm_area_struct *vma)
return res;
 }
 
+/*
+ * Output is disabled temporarily
+ * Zoran is picky about jpeg data it accepts. At least it seems to unsupport 
COM and APPn.
+ * So until a way to filter data will be done, disable output.
+ */
 static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_querycap= zoran_querycap,
.vidioc_s_selection = zoran_s_selection,
@@ -2211,9 +2215,9 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_enum_input  = zoran_enum_input,
.vidioc_g_input = zoran_g_input,
.vidioc_s_input = zoran_s_input,
-   .vidioc_enum_output = zoran_enum_output,
+/* .vidioc_enum_output = zoran_enum_output,
.vidioc_g_output= zoran_g_output,
-   .vidioc_s_output= zoran_s_output,
+   .vidioc_s_output= zoran_s_output,*/
.vidioc_g_fbuf  = zoran_g_fbuf,
.vidioc_s_fbuf  = zoran_s_fbuf,
.vidioc_g_std   = zoran_g_std,
@@ -2227,13 +2231,13 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_streamon= zoran_streamon,
.vidioc_streamoff   = zoran_streamoff,
.vidioc_enum_fmt_vid_cap= zoran_enum_fmt_vid_cap,
-   .vidioc_enum_fmt_vid_out= zoran_enum_fmt_vid_out,
+/* .vidioc_enum_fmt_vid_out= zoran_enum_fmt_vid_out,*/
.vidioc_g_fmt_vid_cap   = zoran_g_fmt_vid_cap,
-   .vidioc_g_fmt_vid_out   = zoran_g_fmt_vid_out,
+/* .vidioc_g_fmt_vid_out   = zoran_g_fmt_vid_out,*/
.vidioc_s_fmt_vid_cap   = zoran_s_fmt_vid_cap,
-   .vidioc_s_fmt_vid_out   = zoran_s_fmt_vid_out,
+/* .vidioc_s_fmt_vid_out   = zoran_s_fmt_vid_out,*/
.vidioc_try_fmt_vid_cap = zoran_try_fmt_vid_cap,
-   .vidioc_try_fmt_vid_out = zoran_try_fmt_vid_out,
+/* .vidioc_try_fmt_vid_out = zoran_try_fmt_vid_out,*/
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
-- 
2.26.2

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


[PATCH RFT/RFC 08/49] staging: media: zoran: convert all error dprintk to pci_err/pr_err

2020-09-21 Thread Corentin Labbe
This patch converts all errors dprintk to pci_err/pr_err.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/videocodec.c   |  39 +--
 drivers/staging/media/zoran/zoran_card.c   |  96 ++
 drivers/staging/media/zoran/zoran_device.c |  28 +-
 drivers/staging/media/zoran/zoran_driver.c | 334 +
 drivers/staging/media/zoran/zoran_procfs.c |   4 +-
 drivers/staging/media/zoran/zr36016.c  |  39 +--
 drivers/staging/media/zoran/zr36050.c  |  10 +-
 drivers/staging/media/zoran/zr36060.c  |  24 +-
 8 files changed, 145 insertions(+), 429 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.c 
b/drivers/staging/media/zoran/videocodec.c
index 3a2f0c450a44..28031d3fd757 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -62,7 +62,7 @@ struct videocodec *videocodec_attach(struct videocodec_master 
*master)
int res;
 
if (!master) {
-   dprintk(1, KERN_ERR "videocodec_attach: no data\n");
+   pr_err("%s: no data\n", __func__);
return NULL;
}
 
@@ -70,9 +70,7 @@ struct videocodec *videocodec_attach(struct videocodec_master 
*master)
master->name, master->flags, master->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_attach: no device available\n");
+   pr_err("%s: no device available\n", __func__);
return NULL;
}
 
@@ -120,7 +118,7 @@ struct videocodec *videocodec_attach(struct 
videocodec_master *master)
h = h->next;
}
 
-   dprintk(1, KERN_ERR "videocodec_attach: no codec found!\n");
+   pr_err("%s: no codec found!\n", __func__);
return NULL;
 
  out_module_put:
@@ -138,7 +136,7 @@ int videocodec_detach(struct videocodec *codec)
int res;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_detach: no data\n");
+   pr_err("%s: no data\n", __func__);
return -EINVAL;
}
 
@@ -146,8 +144,7 @@ int videocodec_detach(struct videocodec *codec)
codec->name, codec->type, codec->flags, codec->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR "videocodec_detach: no device left...\n");
+   pr_err("%s: no device left...\n", __func__);
return -ENXIO;
}
 
@@ -161,10 +158,7 @@ int videocodec_detach(struct videocodec *codec)
dprintk(3, "%s: '%s'\n", __func__, 
a->codec->name);
a->codec->master_data = NULL;
} else {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_detach: '%s'\n",
-   a->codec->name);
+   pr_err("%s: '%s'\n", __func__, 
a->codec->name);
a->codec->master_data = NULL;
}
if (!prev) {
@@ -186,7 +180,7 @@ int videocodec_detach(struct videocodec *codec)
h = h->next;
}
 
-   dprintk(1, KERN_ERR "videocodec_detach: given codec not found!\n");
+   pr_err("%s: given codec not found!\n", __func__);
return -EINVAL;
 }
 EXPORT_SYMBOL(videocodec_detach);
@@ -196,7 +190,7 @@ int videocodec_register(const struct videocodec *codec)
struct codec_list *ptr, *h = codeclist_top;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_register: no data!\n");
+   pr_err("%s: no data!\n", __func__);
return -EINVAL;
}
 
@@ -229,7 +223,7 @@ int videocodec_unregister(const struct videocodec *codec)
struct codec_list *prev = NULL, *h = codeclist_top;
 
if (!codec) {
-   dprintk(1, KERN_ERR "videocodec_unregister: no data!\n");
+   pr_err("%s: no data!\n", __func__);
return -EINVAL;
}
 
@@ -238,19 +232,14 @@ int videocodec_unregister(const struct videocodec *codec)
codec->name, codec->type, codec->flags, codec->magic);
 
if (!h) {
-   dprintk(1,
-   KERN_ERR
-   "videocodec_unregister: no device left...\n");
+   pr_err("%s: no device left...\n", __func__);
return -ENXIO;
}
 
while (h) {
if (codec == h->codec) {
if (h->attached) {
- 

[PATCH RFT/RFC 19/49] staging: media: zoran: move jpg_settings out of zoran_fh

2020-09-21 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the jpg_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|   2 -
 drivers/staging/media/zoran/zoran_driver.c | 103 ++---
 2 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index a529b49888c6..7e6e03563a2a 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -216,8 +216,6 @@ struct zoran_fh {
enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
struct zoran_buffer_col buffers;/* buffers' info */
-
-   struct zoran_jpg_settings jpg_settings; /* structure with a lot of 
things to play with */
 };
 
 struct card_info {
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 984f1dde99d2..f0ceda9a3d44 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -587,9 +587,7 @@ static int zoran_jpg_queue_frame(struct zoran_fh *fh, int 
num,
}
 
/* what is the codec mode right now? */
-   if (zr->codec_mode == BUZ_MODE_IDLE) {
-   zr->jpg_settings = fh->jpg_settings;
-   } else if (zr->codec_mode != mode) {
+   if (zr->codec_mode != BUZ_MODE_IDLE && zr->codec_mode != mode) {
/* wrong codec mode active - invalid */
pci_err(zr->pci_dev, "%s - codec in wrong mode\n", __func__);
return -EINVAL;
@@ -751,9 +749,6 @@ static void zoran_open_init_session(struct zoran_fh *fh)
fh->overlay_settings.format = zr->overlay_settings.format;
fh->overlay_active = ZORAN_FREE;
 
-   /* jpg settings */
-   fh->jpg_settings = zr->jpg_settings;
-
/* buffers */
memset(>buffers, 0, sizeof(fh->buffers));
for (i = 0; i < MAX_FRAME; i++) {
@@ -1237,11 +1232,11 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
}
 
/* which fields are these? */
-   if (fh->jpg_settings.TmpDcm != 1)
-   buf->field = fh->jpg_settings.odd_even ?
+   if (zr->jpg_settings.TmpDcm != 1)
+   buf->field = zr->jpg_settings.odd_even ?
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
else
-   buf->field = fh->jpg_settings.odd_even ?
+   buf->field = zr->jpg_settings.odd_even ?
V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT;
 
break;
@@ -1389,18 +1384,18 @@ static int zoran_enum_fmt_vid_overlay(struct file 
*file, void *__fh,
 
 static int zoran_g_fmt_vid_out(struct file *file, void *__fh, struct 
v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
+   struct zoran *zr = video_drvdata(file);
 
-   fmt->fmt.pix.width = fh->jpg_settings.img_width / 
fh->jpg_settings.HorDcm;
-   fmt->fmt.pix.height = fh->jpg_settings.img_height * 2 /
-   (fh->jpg_settings.VerDcm * fh->jpg_settings.TmpDcm);
-   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
+   fmt->fmt.pix.width = zr->jpg_settings.img_width / 
zr->jpg_settings.HorDcm;
+   fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
+   (zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
+   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
-   if (fh->jpg_settings.TmpDcm == 1)
-   fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+   if (zr->jpg_settings.TmpDcm == 1)
+   fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT);
else
-   fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+   fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
fmt->fmt.pix.bytesperline = 0;
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -1468,15 +1463,14 @@ static int zoran_try_fmt_vid_overlay(struct file *file, 
void *__fh,
 static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
 struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
struct zoran_jpg_settings settings;
int res = 0;
 
if (fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
-   settings = fh->jpg_settings;
+   settings = zr->jpg_settings;
 
/* we actua

[PATCH RFT/RFC 20/49] staging: media: zoran: move overlay_settings out of zoran_fh

2020-09-21 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the overlay_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  1 -
 drivers/staging/media/zoran/zoran_device.c |  8 ++---
 drivers/staging/media/zoran/zoran_driver.c | 40 +-
 3 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 7e6e03563a2a..e9fef23a720c 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -211,7 +211,6 @@ struct zoran_fh {
 
enum zoran_map_mode map_mode;   /* Flag which bufferset will 
map by next mmap() */
 
-   struct zoran_overlay_settings overlay_settings;
u32 *overlay_mask;  /* overlay mask */
enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 4f9b28e63ac0..e81316ac6521 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -508,10 +508,10 @@ void write_overlay_mask(struct zoran_fh *fh, struct 
v4l2_clip *vp, int count)
height += y;
y = 0;
}
-   if (x + width > fh->overlay_settings.width)
-   width = fh->overlay_settings.width - x;
-   if (y + height > fh->overlay_settings.height)
-   height = fh->overlay_settings.height - y;
+   if (x + width > zr->overlay_settings.width)
+   width = zr->overlay_settings.width - x;
+   if (y + height > zr->overlay_settings.height)
+   height = zr->overlay_settings.height - y;
 
/* ignore degenerate clips */
if (height <= 0)
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index f0ceda9a3d44..77cd2c07c394 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -744,9 +744,7 @@ static void zoran_open_init_session(struct zoran_fh *fh)
map_mode_raw(fh);
 
/* take over the card's current settings */
-   fh->overlay_settings = zr->overlay_settings;
-   fh->overlay_settings.is_set = 0;
-   fh->overlay_settings.format = zr->overlay_settings.format;
+   zr->overlay_settings.is_set = 0;
fh->overlay_active = ZORAN_FREE;
 
/* buffers */
@@ -1005,7 +1003,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
return -EINVAL;
}
 
-   if (!fh->overlay_settings.format) {
+   if (!zr->overlay_settings.format) {
pci_err(zr->pci_dev, "%s - no overlay format set\n", __func__);
return -EINVAL;
}
@@ -1043,11 +1041,11 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
return -EINVAL;
}
 
-   fh->overlay_settings.x = x;
-   fh->overlay_settings.y = y;
-   fh->overlay_settings.width = width;
-   fh->overlay_settings.height = height;
-   fh->overlay_settings.clipcount = clipcount;
+   zr->overlay_settings.x = x;
+   zr->overlay_settings.y = y;
+   zr->overlay_settings.width = width;
+   zr->overlay_settings.height = height;
+   zr->overlay_settings.clipcount = clipcount;
 
/*
 * If an overlay is running, we have to switch it off
@@ -1069,7 +1067,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
 */
if (bitmap) {
/* fake value - it just means we want clips */
-   fh->overlay_settings.clipcount = 1;
+   zr->overlay_settings.clipcount = 1;
 
if (copy_from_user(fh->overlay_mask, bitmap,
   (width * height + 7) / 8)) {
@@ -1091,10 +1089,7 @@ static int setup_window(struct zoran_fh *fh, int x, int 
y, int width, int height
vfree(vcp);
}
 
-   fh->overlay_settings.is_set = 1;
-   if (fh->overlay_active != ZORAN_FREE &&
-   zr->overlay_active != ZORAN_FREE)
-   zr->overlay_settings = fh->overlay_settings;
+   zr->overlay_settings.is_set = 1;
 
if (on)
zr36057_overlay(zr, 1);
@@ -1135,18 +1130,17 @@ static int setup_overlay(struct zoran_fh *fh, int on)
zr36057_overlay(zr, 0);
zr->overlay_mask = NULL;
} else {
-   if (!zr->vbuf_base || !fh->overlay_settings.is_set) {
+   if (!zr->vbuf_base || !zr->overlay_settings.is_set) {
  

[PATCH RFT/RFC 17/49] staging: media: zoran: move buffer_size out of zoran_fh

2020-09-21 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the buffer_size directly in the
zoran structure.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  3 +-
 drivers/staging/media/zoran/zoran_device.c |  3 +-
 drivers/staging/media/zoran/zoran_driver.c | 62 +++---
 3 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 1b3eceaead5a..97933c550113 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -195,7 +195,7 @@ enum zoran_lock_activity {
 /* buffer collections */
 struct zoran_buffer_col {
enum zoran_lock_activity active;/* feature currently in use? */
-   unsigned int num_buffers, buffer_size;
+   unsigned int num_buffers;
struct zoran_buffer buffer[MAX_FRAME];  /* buffers */
u8 allocated;   /* Flag if buffers are allocated */
u8 need_contiguous; /* Flag if contiguous buffers are needed */
@@ -292,6 +292,7 @@ struct zoran {
v4l2_std_id norm;
 
/* Current buffer params */
+   unsigned int buffer_size;
void *vbuf_base;
int vbuf_height, vbuf_width;
int vbuf_depth;
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index a33de61a5e9b..4f9b28e63ac0 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -882,8 +882,7 @@ void jpeg_start(struct zoran *zr)
 void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)
 {
struct vfe_settings cap;
-   int field_size =
-   zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff;
+   int field_size = zr->buffer_size / zr->jpg_settings.field_per_buff;
 
zr->codec_mode = mode;
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index a996161cb276..a97faf54e19d 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -178,15 +178,18 @@ static void jpg_fbuffer_free(struct zoran_fh *fh);
 /* Set mapping mode */
 static void map_mode_raw(struct zoran_fh *fh)
 {
+   struct zoran *zr = fh->zr;
fh->map_mode = ZORAN_MAP_MODE_RAW;
-   fh->buffers.buffer_size = v4l_bufsize;
+   zr->buffer_size = v4l_bufsize;
fh->buffers.num_buffers = v4l_nbufs;
 }
 
 static void map_mode_jpg(struct zoran_fh *fh, int play)
 {
+   struct zoran *zr = fh->zr;
+
fh->map_mode = play ? ZORAN_MAP_MODE_JPG_PLAY : ZORAN_MAP_MODE_JPG_REC;
-   fh->buffers.buffer_size = jpg_bufsize;
+   zr->buffer_size = jpg_bufsize;
fh->buffers.num_buffers = jpg_nbufs;
 }
 
@@ -212,7 +215,7 @@ static int v4l_fbuffer_alloc(struct zoran_fh *fh)
pci_warn(zr->pci_dev, "%s - buffer %d already 
allocated!?\n", __func__, i);
 
//udelay(20);
-   mem = kmalloc(fh->buffers.buffer_size, GFP_KERNEL | 
__GFP_NOWARN);
+   mem = kmalloc(zr->buffer_size, GFP_KERNEL | __GFP_NOWARN);
if (!mem) {
pci_err(zr->pci_dev, "%s - kmalloc for V4L buf %d 
failed\n", __func__, i);
v4l_fbuffer_free(fh);
@@ -221,7 +224,7 @@ static int v4l_fbuffer_alloc(struct zoran_fh *fh)
fh->buffers.buffer[i].v4l.fbuffer = mem;
fh->buffers.buffer[i].v4l.fbuffer_phys = virt_to_phys(mem);
fh->buffers.buffer[i].v4l.fbuffer_bus = virt_to_bus(mem);
-   for (off = 0; off < fh->buffers.buffer_size;
+   for (off = 0; off < zr->buffer_size;
 off += PAGE_SIZE)
SetPageReserved(virt_to_page(mem + off));
pci_info(zr->pci_dev, "%s - V4L frame %d mem %p (bus: 
0x%llx)\n", __func__, i, mem,
@@ -247,7 +250,7 @@ static void v4l_fbuffer_free(struct zoran_fh *fh)
continue;
 
mem = fh->buffers.buffer[i].v4l.fbuffer;
-   for (off = 0; off < fh->buffers.buffer_size;
+   for (off = 0; off < zr->buffer_size;
 off += PAGE_SIZE)
ClearPageReserved(virt_to_page(mem + off));
kfree(fh->buffers.buffer[i].v4l.fbuffer);
@@ -307,7 +310,7 @@ static int jpg_fbuffer_alloc(struct zoran_fh *fh)
fh->buffers.buffer[i].jpg.frag_tab_bus = virt_to_bus(mem);
 
if (fh->buffers.need_contiguous) {
-   mem = kmalloc(fh->buffers.buffer_size, GFP_KERNEL);
+   mem = kmalloc(zr->buffer_size, GFP_KERNEL);
if (!mem) {
pci_err(zr->pci_dev, "%s - kmalloc failed for 
buffer %d\n", __func__, i)

[PATCH RFT/RFC 45/49] staging: media: zoran: fix use of buffer_size and sizeimage

2020-09-21 Thread Corentin Labbe
buffer_size was not set when it should be.
Furthermore, use it instead of recalculate it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 2 ++
 drivers/staging/media/zoran/zoran_driver.c | 9 ++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 3bfeb1e00563..e4688891d307 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -852,6 +852,8 @@ void zoran_open_init_params(struct zoran *zr)
if (i)
pci_err(zr->pci_dev, "%s internal error\n", __func__);
 
+   zr->buffer_size = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+
clear_interrupt_counters(zr);
 }
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 46bf8b32d57a..47f397ff190f 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -407,6 +407,8 @@ static int zoran_v4l_set_format(struct zoran *zr, int 
width, int height,
 
bpp = (format->depth + 7) / 8;
 
+   zr->buffer_size = height * width * bpp;
+
/* Check against available buffer size */
if (height * width * bpp > zr->buffer_size) {
pci_err(zr->pci_dev, "%s - video buffer size (%d kB) is too 
small\n",
@@ -1090,7 +1092,7 @@ static int zoran_g_fmt_vid_out(struct file *file, void 
*__fh, struct v4l2_format
fmt->fmt.pix.width = zr->jpg_settings.img_width / 
zr->jpg_settings.HorDcm;
fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
(zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
-   fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(>jpg_settings);
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if (zr->jpg_settings.TmpDcm == 1)
fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
@@ -1114,7 +1116,7 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
 
fmt->fmt.pix.width = zr->v4l_settings.width;
fmt->fmt.pix.height = zr->v4l_settings.height;
-   fmt->fmt.pix.sizeimage = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
@@ -1183,6 +1185,7 @@ static int zoran_try_fmt_vid_out(struct file *file, void 
*__fh,
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 
fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize();
+   zr->buffer_size = fmt->fmt.pix.sizeimage;
fmt->fmt.pix.bytesperline = 0;
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
return res;
@@ -1337,7 +1340,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
 
/* tell the user the results/missing stuff */
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
-   fmt->fmt.pix.sizeimage = zr->v4l_settings.height * 
zr->v4l_settings.bytesperline;
+   fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
-- 
2.26.2

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


[PATCH RFT/RFC 40/49] staging: media: zoran: device support only 32bit DMA address

2020-09-21 Thread Corentin Labbe
The zoran device only supports 32bit DMA address.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 864196e7acae..ab16a70a7451 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1101,6 +1101,12 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
int card_num;
const char *codec_name, *vfe_name;
unsigned int nr;
+   int err;
+
+   err = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (err)
+   return -ENODEV;
+   vb2_dma_contig_set_max_seg_size(>dev, DMA_BIT_MASK(32));
 
nr = zoran_num++;
if (nr >= BUZ_MAX) {
-- 
2.26.2

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


[PATCH RFT/RFC 31/49] staging: media: zoran: use pci_request_regions

2020-09-21 Thread Corentin Labbe
Use pci_request_regions so now we can see zoran in /proc/iomem.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 756b9a339f7e..ed4ecf92c040 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1004,6 +1004,7 @@ static void zoran_remove(struct pci_dev *pdev)
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
+   pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
 exit_free:
@@ -1151,10 +1152,14 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
zr->card = zoran_cards[card_num];
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]", 
zr->card.name, zr->id);
 
+   err = pci_request_regions(pdev, ZR_DEVNAME(zr));
+   if (err)
+   goto zr_unreg;
+
zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
if (!zr->zr36057_mem) {
pci_err(pdev, "%s() - ioremap failed\n", __func__);
-   goto zr_unreg;
+   goto zr_pci_release;
}
 
result = pci_request_irq(pdev, 0, zoran_irq, NULL, zr, ZR_DEVNAME(zr));
@@ -1270,6 +1275,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
pci_free_irq(zr->pci_dev, 0, zr);
 zr_unmap:
iounmap(zr->zr36057_mem);
+zr_pci_release:
+   pci_release_regions(pdev);
 zr_unreg:
v4l2_ctrl_handler_free(>hdl);
v4l2_device_unregister(>v4l2_dev);
-- 
2.26.2

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


[PATCH RFT/RFC 41/49] staging: media: zoran: enable makefile

2020-09-21 Thread Corentin Labbe
This patch enables compilation of the zoran driver.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 25910221b100..965a8b0e6cf2 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_VIDEO_HANTRO)+= hantro/
 obj-$(CONFIG_VIDEO_IPU3_IMGU)  += ipu3/
 obj-$(CONFIG_PHY_ROCKCHIP_DPHY_RX0)+= phy-rockchip-dphy-rx0/
 obj-$(CONFIG_VIDEO_ROCKCHIP_ISP1)  += rkisp1/
+obj-$(CONFIG_VIDEO_ZORAN)  += zoran/
-- 
2.26.2

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


[PATCH RFT/RFC 36/49] staging: media: zoran: Add more check for compliance

2020-09-21 Thread Corentin Labbe
The zoran driver miss some sanity checks, and this made v4l compliance
happy.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 6e95fbf5c7ea..a326c0a16e0c 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1092,6 +1092,11 @@ static int zoran_enum_fmt(struct zoran *zr, struct 
v4l2_fmtdesc *fmt, int flag)
 {
unsigned int num, i;
 
+   if (fmt->index >= ARRAY_SIZE(zoran_formats))
+   return -EINVAL;
+   if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
for (num = i = 0; i < NUM_FORMATS; i++) {
if (zoran_formats[i].flags & flag && num++ == fmt->index) {
strscpy(fmt->description, zoran_formats[i].name, 
sizeof(fmt->description));
@@ -1244,6 +1249,12 @@ static int zoran_try_fmt_vid_cap(struct file *file, void 
*__fh,
if (i == NUM_FORMATS)
return -EINVAL;
 
+   fmt->fmt.pix.colorspace = zoran_formats[i].colorspace;
+   if (BUZ_MAX_HEIGHT < (fmt->fmt.pix.height * 2))
+   fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   else
+   fmt->fmt.pix.field = V4L2_FIELD_TOP;
+
bpp = DIV_ROUND_UP(zoran_formats[i].depth, 8);
v4l_bound_align_image(>fmt.pix.width, BUZ_MIN_WIDTH, 
BUZ_MAX_WIDTH, bpp == 2 ? 1 : 2,
>fmt.pix.height, BUZ_MIN_HEIGHT, BUZ_MAX_HEIGHT, 0, 0);
@@ -1271,6 +1282,9 @@ static int zoran_s_fmt_vid_out(struct file *file, void 
*__fh, struct v4l2_format
return res;
}
 
+   if (!fmt->fmt.pix.height || !fmt->fmt.pix.width)
+   return -EINVAL;
+
settings = zr->jpg_settings;
 
/* we actually need to set 'real' parameters now */
@@ -1856,6 +1870,9 @@ static int zoran_s_selection(struct file *file, void 
*__fh, struct v4l2_selectio
sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   if (!sel->r.width || !sel->r.height)
+   return -EINVAL;
+
if (sel->target != V4L2_SEL_TGT_CROP)
return -EINVAL;
 
-- 
2.26.2

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


[PATCH RFT/RFC 26/49] staging: media: zoran: zoran does not support STD_ALL

2020-09-21 Thread Corentin Labbe
In fact, zoran does not support V4L2_STD_ALL, so let's enumerate what we
support.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index b1351455690f..6e95fbf5c7ea 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1749,7 +1749,7 @@ static int zoran_enum_input(struct file *file, void 
*__fh, struct v4l2_input *in
 
strscpy(inp->name, zr->card.input[inp->index].name, sizeof(inp->name));
inp->type = V4L2_INPUT_TYPE_CAMERA;
-   inp->std = V4L2_STD_ALL;
+   inp->std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM;
 
/* Get status of video decoder */
decoder_call(zr, video, g_input_status, >status);
-- 
2.26.2

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


[PATCH RFT/RFC 33/49] staging: media: zoran: add stat_com buffer

2020-09-21 Thread Corentin Labbe
This patch adds the allocation of the stat_com buffer which be used
later.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h  |  2 ++
 drivers/staging/media/zoran/zoran_card.c | 11 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 87ca324f6ec2..c73b7e7fd5e1 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -357,6 +357,8 @@ struct zoran {
wait_queue_head_t test_q;
 
dma_addr_t p_sc;
+   __le32 *stat_comb;
+   dma_addr_t p_scb;
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 36305aaabd7d..b841f532e6bb 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -944,6 +944,12 @@ static int zr36057_init(struct zoran *zr)
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
 
+   zr->stat_comb = dma_alloc_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM 
* sizeof(u32) * 2, >p_scb, GFP_KERNEL);
+   if (!zr->stat_comb) {
+   err = -ENOMEM;
+   goto exit_statcom;
+   }
+
/* Now add the template and register the device unit. */
*zr->video_dev = zoran_template;
zr->video_dev->v4l2_dev = >v4l2_dev;
@@ -957,7 +963,7 @@ static int zr36057_init(struct zoran *zr)
zr->video_dev->vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
-   goto exit_statcom;
+   goto exit_statcomb;
video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
@@ -972,6 +978,8 @@ static int zr36057_init(struct zoran *zr)
zr->initialized = 1;
return 0;
 
+exit_statcomb:
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 
2, zr->stat_comb, zr->p_scb);
 exit_statcom:
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
 exit_video:
@@ -1003,6 +1011,7 @@ static void zoran_remove(struct pci_dev *pdev)
pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 
2, zr->stat_comb, zr->p_scb);
pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
-- 
2.26.2

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


[PATCH RFT/RFC 44/49] staging: media: zoran: remove test_interrupts

2020-09-21 Thread Corentin Labbe
The test_interrupts function is useless, remove it.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  3 ---
 drivers/staging/media/zoran/zoran_card.c   | 27 --
 drivers/staging/media/zoran/zoran_device.c | 16 -
 3 files changed, 46 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 0246635e0eac..fd27d1968e60 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -345,7 +345,6 @@ struct zoran {
struct zoran_buffer_col jpg_buffers;/* MJPEG buffers' info */
 
/* Additional stuff for testing */
-   int testing;
int jpeg_error;
int intr_counter_GIRQ1;
int intr_counter_GIRQ0;
@@ -372,8 +371,6 @@ struct zoran {
int running;
int buf_in_reserve;
 
-   wait_queue_head_t test_q;
-
dma_addr_t p_sc;
__le32 *stat_comb;
dma_addr_t p_scb;
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 530dd326ad94..3bfeb1e00563 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -853,31 +853,6 @@ void zoran_open_init_params(struct zoran *zr)
pci_err(zr->pci_dev, "%s internal error\n", __func__);
 
clear_interrupt_counters(zr);
-   zr->testing = 0;
-}
-
-static void test_interrupts(struct zoran *zr)
-{
-   DEFINE_WAIT(wait);
-   int timeout, icr;
-
-   clear_interrupt_counters(zr);
-
-   zr->testing = 1;
-   icr = btread(ZR36057_ICR);
-   btwrite(0x7800 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
-   prepare_to_wait(>test_q, , TASK_INTERRUPTIBLE);
-   timeout = schedule_timeout(HZ);
-   finish_wait(>test_q, );
-   btwrite(0, ZR36057_ICR);
-   btwrite(0x7800, ZR36057_ISR);
-   zr->testing = 0;
-   pci_info(zr->pci_dev, "Testing interrupts...\n");
-   if (timeout)
-   pci_info(zr->pci_dev, ": time spent: %d\n", 1 * HZ - timeout);
-   if (zr36067_debug > 1)
-   print_interrupts(zr);
-   btwrite(icr, ZR36057_ICR);
 }
 
 static int zr36057_init(struct zoran *zr)
@@ -891,7 +866,6 @@ static int zr36057_init(struct zoran *zr)
 
init_waitqueue_head(>v4l_capq);
init_waitqueue_head(>jpg_capq);
-   init_waitqueue_head(>test_q);
zr->jpg_buffers.allocated = 0;
zr->v4l_buffers.allocated = 0;
 
@@ -968,7 +942,6 @@ static int zr36057_init(struct zoran *zr)
zoran_init_hardware(zr);
if (zr36067_debug > 2)
detect_guest_activity(zr);
-   test_interrupts(zr);
if (!pass_through) {
decoder_call(zr, video, s_stream, 0);
encoder_call(zr, video, s_routing, 2, 0, 0);
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 7634d94f9359..ae4abf8ffa36 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -1099,22 +1099,6 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
struct zoran *zr = dev_id;
unsigned long flags;
 
-   if (zr->testing) {
-   /* Testing interrupts */
-   spin_lock_irqsave(>spinlock, flags);
-   while ((stat = count_reset_interrupt(zr))) {
-   if (count++ > 100) {
-   btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
-   pci_err(zr->pci_dev, "IRQ lockup while testing, 
isr=0x%08x, cleared int mask\n",
-   stat);
-   wake_up_interruptible(>test_q);
-   }
-   }
-   zr->last_isr = stat;
-   spin_unlock_irqrestore(>spinlock, flags);
-   return IRQ_HANDLED;
-   }
-
spin_lock_irqsave(>spinlock, flags);
while (1) {
/* get/clear interrupt status bits */
-- 
2.26.2

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


[PATCH RFT/RFC 35/49] staging: media: zoran: constify codec_name

2020-09-21 Thread Corentin Labbe
The codec_name could be const.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 176ce8a355ba..d956bd45194f 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -254,9 +254,9 @@ static void avs6eyes_init(struct zoran *zr)
GPIO(zr, 7, mux & 4);   /* MUX S2 */
 }
 
-static char *codecid_to_modulename(u16 codecid)
+static const char *codecid_to_modulename(u16 codecid)
 {
-   char *name = NULL;
+   const char *name = NULL;
 
switch (codecid) {
case CODEC_TYPE_ZR36060:
@@ -1092,7 +1092,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
struct videocodec_master *master_vfe = NULL;
struct videocodec_master *master_codec = NULL;
int card_num;
-   char *codec_name, *vfe_name;
+   const char *codec_name, *vfe_name;
unsigned int nr;
 
nr = zoran_num++;
-- 
2.26.2

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


[PATCH RFT/RFC 25/49] staging: media: zoran: use ZR_NORM

2020-09-21 Thread Corentin Labbe
Instead of using hardcoded numbers, let's use some define for ZR NORM.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h| 4 
 drivers/staging/media/zoran/zoran_card.c   | 8 
 drivers/staging/media/zoran/zoran_driver.c | 6 +++---
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 8f3faa4eb60f..87ca324f6ec2 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -22,6 +22,10 @@
 #include 
 #include 
 
+#define ZR_NORM_PAL 0
+#define ZR_NORM_NTSC 1
+#define ZR_NORM_SECAM 2
+
 struct zoran_sync {
unsigned long frame;/* number of buffer that has been free'd */
unsigned long length;   /* number of code bytes in buffer (capture 
only) */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index a8d23bf126c3..1c587ce0d8c0 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -906,18 +906,18 @@ static int zr36057_init(struct zoran *zr)
default_norm = 0;
if (default_norm == 0) {
zr->norm = V4L2_STD_PAL;
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
} else if (default_norm == 1) {
zr->norm = V4L2_STD_NTSC;
-   zr->timing = zr->card.tvn[1];
+   zr->timing = zr->card.tvn[ZR_NORM_NTSC];
} else {
zr->norm = V4L2_STD_SECAM;
-   zr->timing = zr->card.tvn[2];
+   zr->timing = zr->card.tvn[ZR_NORM_SECAM];
}
if (!zr->timing) {
pci_warn(zr->pci_dev, "%s - default TV standard not supported 
by hardware. PAL will be used.\n", __func__);
zr->norm = V4L2_STD_PAL;
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
}
 
if (default_input > zr->card.inputs - 1) {
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 8724b0ad855e..b1351455690f 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1033,11 +1033,11 @@ static int zoran_set_norm(struct zoran *zr, v4l2_std_id 
norm)
}
 
if (norm & V4L2_STD_SECAM)
-   zr->timing = zr->card.tvn[2];
+   zr->timing = zr->card.tvn[ZR_NORM_SECAM];
else if (norm & V4L2_STD_NTSC)
-   zr->timing = zr->card.tvn[1];
+   zr->timing = zr->card.tvn[ZR_NORM_NTSC];
else
-   zr->timing = zr->card.tvn[0];
+   zr->timing = zr->card.tvn[ZR_NORM_PAL];
 
decoder_call(zr, video, s_std, norm);
encoder_call(zr, video, s_std_output, norm);
-- 
2.26.2

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


[PATCH RFT/RFC 10/49] staging: media: zoran: convert dprintk info to pci_info

2020-09-21 Thread Corentin Labbe
This patch convert dprintk(info) to pci_info (or pci_dbg if the message
is not important).

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 46 +++---
 drivers/staging/media/zoran/zoran_device.c | 27 -
 drivers/staging/media/zoran/zoran_driver.c | 34 ++--
 3 files changed, 36 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 26f58e687333..fd633265761c 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -887,9 +887,9 @@ static void test_interrupts(struct zoran *zr)
btwrite(0, ZR36057_ICR);
btwrite(0x7800, ZR36057_ISR);
zr->testing = 0;
-   dprintk(5, KERN_INFO "%s: Testing interrupts...\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Testing interrupts...\n");
if (timeout)
-   dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
+   pci_info(zr->pci_dev, ": time spent: %d\n", 1 * HZ - timeout);
if (zr36067_debug > 1)
print_interrupts(zr);
btwrite(icr, ZR36057_ICR);
@@ -899,10 +899,7 @@ static int zr36057_init(struct zoran *zr)
 {
int j, err;
 
-   dprintk(1,
-   KERN_INFO
-   "%s: %s - initializing card[%d], zr=%p\n",
-   ZR_DEVNAME(zr), __func__, zr->id, zr);
+   pci_info(zr->pci_dev, "initializing card[%d]\n", zr->id);
 
/* default setup of all parameters which will persist between opens */
zr->user = 0;
@@ -1134,18 +1131,12 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto zr_unreg;
zr->revision = zr->pci_dev->revision;
 
-   dprintk(1,
-   KERN_INFO
-   "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
-   ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
-   zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
-   if (zr->revision >= 2) {
-   dprintk(1,
-   KERN_INFO
-   "%s: Subsystem vendor=0x%04x id=0x%04x\n",
-   ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
-   zr->pci_dev->subsystem_device);
-   }
+   pci_info(zr->pci_dev, "Zoran ZR360%c7 (rev %d), irq: %d, memory: 
0x%08llx\n",
+zr->revision < 2 ? '5' : '6', zr->revision,
+zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 
0));
+   if (zr->revision >= 2)
+   pci_info(zr->pci_dev, "Subsystem vendor=0x%04x id=0x%04x\n",
+zr->pci_dev->subsystem_vendor, 
zr->pci_dev->subsystem_device);
 
/* Use auto-detected card type? */
if (card[nr] == -1) {
@@ -1208,14 +1199,13 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 );
need_latency = zr->revision > 1 ? 32 : 48;
if (latency != need_latency) {
-   dprintk(2, KERN_INFO "%s: Changing PCI latency from %d to %d\n",
-   ZR_DEVNAME(zr), latency, need_latency);
+   pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n", 
latency, need_latency);
pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, 
need_latency);
}
 
zr36057_restart(zr);
/* i2c */
-   dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Initializing i2c bus...\n");
 
if (zoran_register_i2c(zr) < 0) {
pci_err(pdev, "%s - can't initialize i2c bus\n", __func__);
@@ -1229,7 +1219,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zr->encoder = v4l2_i2c_new_subdev(>v4l2_dev, 
>i2c_adapter,
  zr->card.i2c_encoder, 0, 
zr->card.addrs_encoder);
 
-   dprintk(2, KERN_INFO "%s: Initializing videocodec bus...\n", 
ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Initializing videocodec bus...\n");
 
if (zr->card.video_codec) {
codec_name = codecid_to_modulename(zr->card.video_codec);
@@ -1285,9 +1275,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
/* take care of Natoma chipset and a revision 1 zr36057 */
if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
zr->jpg_buffers.need_contiguous = 1;
-   dprintk(1, KERN_INFO
-   "%s: ZR

[PATCH RFT/RFC 24/49] staging: media: zoran: Use DMA coherent for stat_com

2020-09-21 Thread Corentin Labbe
Instead of using a fragile virt_to_bus, let's use proper DMA coherent
for the stat_com entry.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  2 ++
 drivers/staging/media/zoran/zoran_card.c   | 20 +---
 drivers/staging/media/zoran/zoran_device.c |  3 +--
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index aa2a8f688a01..8f3faa4eb60f 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -351,6 +351,8 @@ struct zoran {
unsigned long frame_num;
 
wait_queue_head_t test_q;
+
+   dma_addr_t p_sc;
 };
 
 static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 3a7895be3341..a8d23bf126c3 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -931,11 +931,15 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
zr->video_dev = video_device_alloc();
-   if (!zr->stat_com || !zr->video_dev) {
+   if (!zr->video_dev) {
err = -ENOMEM;
-   goto exit_free;
+   goto exit;
+   }
+   zr->stat_com = dma_alloc_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * 
sizeof(u32), >p_sc, GFP_KERNEL);
+   if (!zr->stat_com) {
+   err = -ENOMEM;
+   goto exit_video;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -953,7 +957,7 @@ static int zr36057_init(struct zoran *zr)
zr->video_dev->vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
-   goto exit_free;
+   goto exit_statcom;
video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
@@ -968,9 +972,11 @@ static int zr36057_init(struct zoran *zr)
zr->initialized = 1;
return 0;
 
-exit_free:
-   kfree(zr->stat_com);
+exit_statcom:
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
+exit_video:
kfree(zr->video_dev);
+exit:
return err;
 }
 
@@ -1004,7 +1010,7 @@ static void zoran_remove(struct pci_dev *pdev)
btwrite(0, ZR36057_SPGPPCR);
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
-   kfree(zr->stat_com);
+   dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index e3104b534471..3a353130afb9 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -576,8 +576,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
//btor(ZR36057_VFESPFR_VCLKPol, ZR36057_VFESPFR);
 
/* code base address */
-   reg = virt_to_bus(zr->stat_com);
-   btwrite(reg, ZR36057_JCBA);
+   btwrite(zr->p_sc, ZR36057_JCBA);
 
/* FIFO threshold (FIFO is 160. double words) */
/* NOTE: decimal values here */
-- 
2.26.2

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


[PATCH RFT/RFC 15/49] staging: media: zoran: use v4l2_buffer_set_timestamp

2020-09-21 Thread Corentin Labbe
The ns_to_timeval function is removed, so replace it with
v4l2_buffer_set_timestamp().

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 31ed36906204..a996161cb276 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1197,7 +1197,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
fh->buffers.buffer[num].state == BUZ_STATE_USER) {
buf->sequence = fh->buffers.buffer[num].bs.seq;
buf->flags |= V4L2_BUF_FLAG_DONE;
-   buf->timestamp = 
ns_to_timeval(fh->buffers.buffer[num].bs.ts);
+   v4l2_buffer_set_timestamp(buf, 
fh->buffers.buffer[num].bs.ts);
} else {
buf->flags |= V4L2_BUF_FLAG_QUEUED;
}
@@ -1228,7 +1228,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
if (fh->buffers.buffer[num].state == BUZ_STATE_DONE ||
fh->buffers.buffer[num].state == BUZ_STATE_USER) {
buf->sequence = fh->buffers.buffer[num].bs.seq;
-   buf->timestamp = 
ns_to_timeval(fh->buffers.buffer[num].bs.ts);
+   v4l2_buffer_set_timestamp(buf, 
fh->buffers.buffer[num].bs.ts);
buf->bytesused = fh->buffers.buffer[num].bs.length;
buf->flags |= V4L2_BUF_FLAG_DONE;
} else {
-- 
2.26.2

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


[PATCH RFT/RFC 21/49] staging: media: zoran: Use video_drvdata to get struct zoran

2020-09-21 Thread Corentin Labbe
Using video_drvdata() is proper and shorter than using directly
fh pointers.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 40 --
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 77cd2c07c394..9d39e98c9af1 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1320,8 +1320,7 @@ static int zoran_set_input(struct zoran *zr, int input)
 
 static int zoran_querycap(struct file *file, void *__fh, struct 
v4l2_capability *cap)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
@@ -1352,8 +1351,7 @@ static int zoran_enum_fmt(struct zoran *zr, struct 
v4l2_fmtdesc *fmt, int flag)
 static int zoran_enum_fmt_vid_cap(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_CAPTURE);
 }
@@ -1361,8 +1359,7 @@ static int zoran_enum_fmt_vid_cap(struct file *file, void 
*__fh,
 static int zoran_enum_fmt_vid_out(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_PLAYBACK);
 }
@@ -1370,8 +1367,7 @@ static int zoran_enum_fmt_vid_out(struct file *file, void 
*__fh,
 static int zoran_enum_fmt_vid_overlay(struct file *file, void *__fh,
  struct v4l2_fmtdesc *f)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
return zoran_enum_fmt(zr, f, ZORAN_FORMAT_OVERLAY);
 }
@@ -1421,8 +1417,7 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
 static int zoran_g_fmt_vid_overlay(struct file *file, void *__fh,
   struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
fmt->fmt.win.w.left = zr->overlay_settings.x;
fmt->fmt.win.w.top = zr->overlay_settings.y;
@@ -1439,8 +1434,7 @@ static int zoran_g_fmt_vid_overlay(struct file *file, 
void *__fh,
 static int zoran_try_fmt_vid_overlay(struct file *file, void *__fh,
 struct v4l2_format *fmt)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH)
fmt->fmt.win.w.width = BUZ_MAX_WIDTH;
@@ -1641,8 +1635,8 @@ static int zoran_s_fmt_vid_out(struct file *file, void 
*__fh, struct v4l2_format
 
 static int zoran_s_fmt_vid_cap(struct file *file, void *__fh, struct 
v4l2_format *fmt)
 {
+   struct zoran *zr = video_drvdata(file);
struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
int i;
int res = 0;
 
@@ -1689,8 +1683,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
 static int zoran_g_fbuf(struct file *file, void *__fh,
struct v4l2_framebuffer *fb)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
memset(fb, 0, sizeof(*fb));
fb->base = zr->vbuf_base;
@@ -1709,8 +1702,8 @@ static int zoran_g_fbuf(struct file *file, void *__fh,
 static int zoran_s_fbuf(struct file *file, void *__fh,
const struct v4l2_framebuffer *fb)
 {
+   struct zoran *zr = video_drvdata(file);
struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
int i, res = 0;
__le32 printformat = __cpu_to_le32(fb->fmt.pixelformat);
 
@@ -2042,8 +2035,7 @@ static int zoran_streamoff(struct file *file, void *__fh, 
enum v4l2_buf_type typ
 
 static int zoran_g_std(struct file *file, void *__fh, v4l2_std_id *std)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
 
*std = zr->norm;
return 0;
@@ -2051,8 +2043,7 @@ static int zoran_g_std(struct file *file, void *__fh, 
v4l2_std_id *std)
 
 static int zoran_s_std(struct file *file, void *__fh, v4l2_std_id std)
 {
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
+   struct zoran *zr = video_drvdata(file);
int res = 0;
 
res = zoran_set_norm(zr, std);
@@ -2065,8 +2056,7 

[PATCH RFT/RFC 22/49] staging: media: zoran: Change zoran_v4l_set_format parameter from zoran_fh to zoran

2020-09-21 Thread Corentin Labbe
We need to get rid of zoran_fh, so let's change function arguments.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 9d39e98c9af1..078575334b5d 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -401,11 +401,9 @@ static void jpg_fbuffer_free(struct zoran_fh *fh)
 /*
  *   V4L Buffer grabbing
  */
-
-static int zoran_v4l_set_format(struct zoran_fh *fh, int width, int height,
+static int zoran_v4l_set_format(struct zoran *zr, int width, int height,
const struct zoran_format *format)
 {
-   struct zoran *zr = fh->zr;
int bpp;
 
/* Check size and format of the grab wanted */
@@ -1665,7 +1663,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
 
map_mode_raw(fh);
 
-   res = zoran_v4l_set_format(fh, fmt->fmt.pix.width, fmt->fmt.pix.height, 
_formats[i]);
+   res = zoran_v4l_set_format(zr, fmt->fmt.pix.width, fmt->fmt.pix.height, 
_formats[i]);
if (res)
return res;
 
-- 
2.26.2

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


[PATCH RFT/RFC 02/49] MAINTAINERS: change maintainer of the zoran driver

2020-09-21 Thread Corentin Labbe
Add myself as maintainer.

Signed-off-by: Corentin Labbe 
---
 Documentation/media/v4l-drivers/zoran.rst  | 22 +++---
 MAINTAINERS| 10 ++
 drivers/staging/media/zoran/zoran_card.c   |  5 -
 drivers/staging/media/zoran/zoran_card.h   |  5 -
 drivers/staging/media/zoran/zoran_device.c |  5 -
 drivers/staging/media/zoran/zoran_device.h |  5 -
 6 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/Documentation/media/v4l-drivers/zoran.rst 
b/Documentation/media/v4l-drivers/zoran.rst
index d2724a863d1d..a0586514cd8a 100644
--- a/Documentation/media/v4l-drivers/zoran.rst
+++ b/Documentation/media/v4l-drivers/zoran.rst
@@ -549,21 +549,13 @@ at high verbosity. See 'Contacting' on how to contact the 
developers.
 Maintainers/Contacting
 --
 
-The driver is currently maintained by Laurent Pinchart and Ronald Bultje
-( and ). For bug
-reports or questions, please contact the mailinglist instead of the developers
-individually. For user questions (i.e. bug reports or how-to questions), send
-an email to , for developers (i.e. if you want to
-help programming), send an email to . See
-http://www.sf.net/projects/mjpeg/ for subscription information.
-
-For bug reports, be sure to include all the information as described in
-the section 'It hangs/crashes/fails/whatevers! Help!'. Please make sure
-you're using the latest version (http://mjpeg.sf.net/driver-zoran/).
-
-Previous maintainers/developers of this driver include Serguei Miridonov
-, Wolfgang Scherr , Dave Perks
- and Rainer Johanni .
+Previous maintainers/developers of this driver are
+- Laurent Pinchart 
+- Ronald Bultje rbul...@ronald.bitfreak.net
+- Serguei Miridonov 
+- Wolfgang Scherr 
+- Dave Perks 
+- Rainer Johanni 
 
 Driver's License
 
diff --git a/MAINTAINERS b/MAINTAINERS
index d3126fc2cca2..f2ece9826be3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19233,6 +19233,16 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs.git
 F: Documentation/filesystems/zonefs.rst
 F: fs/zonefs/
 
+ZR36067 VIDEO FOR LINUX DRIVER
+M: Corentin Labbe 
+L: mjpeg-us...@lists.sourceforge.net
+L: linux-me...@vger.kernel.org
+S: Maintained
+W: http://mjpeg.sourceforge.net/driver-zoran/
+Q: https://patchwork.linuxtv.org/project/linux-media/list/
+F: drivers/staging/media/zoran/
+F: Documentation/media/v4l-drivers/zoran.rst
+
 ZPOOL COMPRESSED PAGE STORAGE API
 M: Dan Streetman 
 L: linux...@kvack.org
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index ea10523194e8..d2f82894e8ee 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_card.h 
b/drivers/staging/media/zoran/zoran_card.h
index 0cdb7d34926d..53ed511ce546 100644
--- a/drivers/staging/media/zoran/zoran_card.h
+++ b/drivers/staging/media/zoran/zoran_card.h
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 22b27632762d..04162be80420 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/staging/media/zoran/zoran_device.h 
b/drivers/staging/media/zoran/zoran_device.h
index a507aaad4ebb..816d48b09be9 100644
--- a/drivers/staging/media/zoran/zoran_device.h
+++ b/drivers/staging/media/zoran/zoran_device.h
@@ -7,11 +7,6 @@
  *
  * Copyright (C) 2000 Serguei Miridonov 
  *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published

[PATCH RFT/RFC 32/49] staging: media: zoran: use devm_ioremap

2020-09-21 Thread Corentin Labbe
Using devm_ioremap simplify code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index ed4ecf92c040..36305aaabd7d 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1003,7 +1003,6 @@ static void zoran_remove(struct pci_dev *pdev)
pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
-   iounmap(zr->zr36057_mem);
pci_release_regions(pdev);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
@@ -1156,7 +1155,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (err)
goto zr_unreg;
 
-   zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
+   zr->zr36057_mem = devm_ioremap(>dev, pci_resource_start(pdev, 0), 
pci_resource_len(pdev, 0));
if (!zr->zr36057_mem) {
pci_err(pdev, "%s() - ioremap failed\n", __func__);
goto zr_pci_release;
@@ -1172,7 +1171,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
} else {
pci_err(pdev, "%s - cannot assign IRQ, error code 
%d\n", __func__, result);
}
-   goto zr_unmap;
+   goto zr_pci_release;
}
 
/* set PCI latency timer */
@@ -1273,8 +1272,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 zr_free_irq:
btwrite(0, ZR36057_SPGPPCR);
pci_free_irq(zr->pci_dev, 0, zr);
-zr_unmap:
-   iounmap(zr->zr36057_mem);
 zr_pci_release:
pci_release_regions(pdev);
 zr_unreg:
-- 
2.26.2

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


[PATCH RFT/RFC 12/49] staging: media: zoran: zoran_device.c: convert pr_x to pci_x

2020-09-21 Thread Corentin Labbe
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 516a7f18ce7a..03ad3562a807 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -162,7 +162,7 @@ static void dump_guests(struct zoran *zr)
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest[i] = post_office_read(zr, i, 0);
 
-   pr_info("%s: Guests: %*ph\n", ZR_DEVNAME(zr), 8, guest);
+   pci_info(zr->pci_dev, "Guests: %*ph\n", 8, guest);
}
 }
 
@@ -172,7 +172,7 @@ void detect_guest_activity(struct zoran *zr)
ktime_t t0, t1;
 
dump_guests(zr);
-   pr_info("%s: Detecting guests activity, please wait...\n", 
ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "Detecting guests activity, please wait...\n");
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest0[i] = guest[i] = post_office_read(zr, i, 0);
 
@@ -198,15 +198,14 @@ void detect_guest_activity(struct zoran *zr)
break;
}
 
-   pr_info("%s: Guests: %*ph\n", ZR_DEVNAME(zr), 8, guest0);
+   pci_info(zr->pci_dev, "Guests: %*ph\n", 8, guest0);
 
if (j == 0) {
-   pr_info("%s: No activity detected.\n", ZR_DEVNAME(zr));
+   pci_info(zr->pci_dev, "No activity detected.\n");
return;
}
for (i = 0; i < j; i++)
-   pr_info("%s: %6d: %d => 0x%02x\n", ZR_DEVNAME(zr),
-   change[i][0], change[i][1], change[i][2]);
+   pci_info(zr->pci_dev, "%6d: %d => 0x%02x\n", change[i][0], 
change[i][1], change[i][2]);
 }
 
 /*
-- 
2.26.2

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


[PATCH RFT/RFC 09/49] staging: media: zoran: convert dprintk warn

2020-09-21 Thread Corentin Labbe
This patch convert dprintk(warn) to pci_warn.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 18 --
 drivers/staging/media/zoran/zoran_device.c | 13 +++---
 drivers/staging/media/zoran/zoran_driver.c | 29 +-
 3 files changed, 14 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 006f209c40ea..26f58e687333 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -933,19 +933,14 @@ static int zr36057_init(struct zoran *zr)
zr->timing = zr->card.tvn[2];
}
if (!zr->timing) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: %s - default TV standard not supported by 
hardware. PAL will be used.\n",
-   ZR_DEVNAME(zr), __func__);
+   pci_warn(zr->pci_dev, "%s - default TV standard not supported 
by hardware. PAL will be used.\n", __func__);
zr->norm = V4L2_STD_PAL;
zr->timing = zr->card.tvn[0];
}
 
if (default_input > zr->card.inputs - 1) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: default_input value %d out of range (0-%d)\n",
-   ZR_DEVNAME(zr), default_input, zr->card.inputs - 1);
+   pci_warn(zr->pci_dev, "default_input value %d out of range 
(0-%d)\n",
+default_input, zr->card.inputs - 1);
default_input = 0;
}
zr->input = default_input;
@@ -1369,11 +1364,8 @@ static int __init zoran_init(void)
}
 
/* some mainboards might not do PCI-PCI data transfer well */
-   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK)) {
-   dprintk(1,
-   KERN_WARNING
-   "%s: chipset does not support reliable PCI-PCI DMA\n", 
ZORAN_NAME);
-   }
+   if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
+   pr_warn("%s: chipset does not support reliable PCI-PCI DMA\n", 
ZORAN_NAME);
 
res = pci_register_driver(_driver);
if (res) {
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index d7c85787e9c0..a04fbae30745 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -547,10 +547,7 @@ void zr36057_set_memgrab(struct zoran *zr, int mode)
 * will be stuck at 1 until capturing is turned back on.
 */
if (btread(ZR36057_VSSFGR) & ZR36057_VSSFGR_SnapShot)
-   dprintk(1,
-   KERN_WARNING
-   "%s: zr36057_set_memgrab(1) with SnapShot 
on!?\n",
-   ZR_DEVNAME(zr));
+   pci_warn(zr->pci_dev, "zr36057_set_memgrab(1) with 
SnapShot on!?\n");
 
/* switch on VSync interrupts */
btwrite(IRQ_MASK, ZR36057_ISR); // Clear Interrupts
@@ -1284,10 +1281,7 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
if (zr->v4l_memgrab_active) {
/* A lot more checks should be here ... */
if ((btread(ZR36057_VSSFGR) & 
ZR36057_VSSFGR_SnapShot) == 0)
-   dprintk(1,
-   KERN_WARNING
-   "%s: BuzIRQ with SnapShot off 
???\n",
-   ZR_DEVNAME(zr));
+   pci_warn(zr->pci_dev, "BuzIRQ with 
SnapShot off ???\n");
 
if (zr->v4l_grab_frame != NO_GRAB_ACTIVE) {
/* There is a grab on a frame going on, 
check if it has finished */
@@ -1406,8 +1400,7 @@ irqreturn_t zoran_irq(int irq, void *dev_id)
 
count++;
if (count > 10) {
-   dprintk(2, KERN_WARNING "%s: irq loop %d\n",
-   ZR_DEVNAME(zr), count);
+   pci_warn(zr->pci_dev, "irq loop %d\n", count);
if (count > 20) {
btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
pci_err(zr->pci_dev, "IRQ lockup, cleared int 
mask\n");
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 4082d5e53a24..3b061c3e4a82 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/

[PATCH RFT/RFC 18/49] staging: media: zoran: move v4l_settings out of zoran_fh

2020-09-21 Thread Corentin Labbe
We need to get rid of zoran_fh, so move the v4l_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran.h|  1 -
 drivers/staging/media/zoran/zoran_driver.c | 38 ++
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 97933c550113..a529b49888c6 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -217,7 +217,6 @@ struct zoran_fh {
 
struct zoran_buffer_col buffers;/* buffers' info */
 
-   struct zoran_v4l_settings v4l_settings; /* structure with a lot of 
things to play with */
struct zoran_jpg_settings jpg_settings; /* structure with a lot of 
things to play with */
 };
 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index a97faf54e19d..984f1dde99d2 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -432,10 +432,10 @@ static int zoran_v4l_set_format(struct zoran_fh *fh, int 
width, int height,
return -EINVAL;
}
 
-   fh->v4l_settings.width = width;
-   fh->v4l_settings.height = height;
-   fh->v4l_settings.format = format;
-   fh->v4l_settings.bytesperline = bpp * fh->v4l_settings.width;
+   zr->v4l_settings.width = width;
+   zr->v4l_settings.height = height;
+   zr->v4l_settings.format = format;
+   zr->v4l_settings.bytesperline = bpp * zr->v4l_settings.width;
 
return 0;
 }
@@ -489,7 +489,7 @@ static int zoran_v4l_queue_frame(struct zoran_fh *fh, int 
num)
zr->v4l_pend[zr->v4l_pend_head++ & V4L_MASK_FRAME] = 
num;
zr->v4l_buffers.buffer[num].state = BUZ_STATE_PEND;
zr->v4l_buffers.buffer[num].bs.length =
-   fh->v4l_settings.bytesperline *
+   zr->v4l_settings.bytesperline *
zr->v4l_settings.height;
fh->buffers.buffer[num] = zr->v4l_buffers.buffer[num];
break;
@@ -751,8 +751,6 @@ static void zoran_open_init_session(struct zoran_fh *fh)
fh->overlay_settings.format = zr->overlay_settings.format;
fh->overlay_active = ZORAN_FREE;
 
-   /* v4l settings */
-   fh->v4l_settings = zr->v4l_settings;
/* jpg settings */
fh->jpg_settings = zr->jpg_settings;
 
@@ -1205,7 +1203,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
buf->flags |= V4L2_BUF_FLAG_QUEUED;
}
 
-   if (fh->v4l_settings.height <= BUZ_MAX_HEIGHT / 2)
+   if (zr->v4l_settings.height <= BUZ_MAX_HEIGHT / 2)
buf->field = V4L2_FIELD_TOP;
else
buf->field = V4L2_FIELD_INTERLACED;
@@ -1418,14 +1416,13 @@ static int zoran_g_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
if (fh->map_mode != ZORAN_MAP_MODE_RAW)
return zoran_g_fmt_vid_out(file, fh, fmt);
 
-   fmt->fmt.pix.width = fh->v4l_settings.width;
-   fmt->fmt.pix.height = fh->v4l_settings.height;
-   fmt->fmt.pix.sizeimage = fh->v4l_settings.bytesperline *
-   fh->v4l_settings.height;
-   fmt->fmt.pix.pixelformat = fh->v4l_settings.format->fourcc;
-   fmt->fmt.pix.colorspace = fh->v4l_settings.format->colorspace;
-   fmt->fmt.pix.bytesperline = fh->v4l_settings.bytesperline;
-   if (BUZ_MAX_HEIGHT < (fh->v4l_settings.height * 2))
+   fmt->fmt.pix.width = zr->v4l_settings.width;
+   fmt->fmt.pix.height = zr->v4l_settings.height;
+   fmt->fmt.pix.sizeimage = zr->v4l_settings.bytesperline * 
zr->v4l_settings.height;
+   fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc;
+   fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
+   fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
else
fmt->fmt.pix.field = V4L2_FIELD_TOP;
@@ -1691,10 +1688,10 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
return res;
 
/* tell the user the results/missing stuff */
-   fmt->fmt.pix.bytesperline = fh->v4l_settings.bytesperline;
-   fmt->fmt.pix.sizeimage = fh->v4l_settings.height * 
fh->v4l_settings.bytesperline;
-   fmt->fmt.pix.colorspace = fh->v4l_settings.format->colorspace;
-   if (BUZ_MAX_HEIGHT < (fh->v4l_setti

[PATCH RFT/RFC 37/49] staging: media: zoran: add fallthrough keyword

2020-09-21 Thread Corentin Labbe
This patch adds fallthrough keyword where appropriate.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 9558bafdde7d..7634d94f9359 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -268,7 +268,9 @@ static void zr36057_adjust_vfe(struct zoran *zr, enum 
zoran_codec_mode mode)
btwrite(reg, ZR36057_VFEHCR);
break;
case BUZ_MODE_MOTION_COMPRESS:
+   fallthrough;
case BUZ_MODE_IDLE:
+   fallthrough;
default:
if ((zr->norm & V4L2_STD_NTSC) ||
(zr->card.type == LML33R10 &&
@@ -521,6 +523,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
/* MJPEG compression mode */
switch (mode) {
case BUZ_MODE_MOTION_COMPRESS:
+   fallthrough;
default:
reg = ZR36057_JMC_MJPGCmpMode;
break;
@@ -582,6 +585,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
/* NOTE: decimal values here */
switch (mode) {
case BUZ_MODE_STILL_COMPRESS:
+   fallthrough;
case BUZ_MODE_MOTION_COMPRESS:
if (zr->card.type != BUZ)
reg = 140;
@@ -590,6 +594,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
break;
 
case BUZ_MODE_STILL_DECOMPRESS:
+   fallthrough;
case BUZ_MODE_MOTION_DECOMPRESS:
reg = 20;
break;
@@ -827,6 +832,7 @@ void zr36057_enable_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
break;
 
case BUZ_MODE_IDLE:
+   fallthrough;
default:
/* shut down processing */
btand(~(zr->card.jpeg_int | ZR36057_ICR_JPEGRepIRQ), 
ZR36057_ICR);
-- 
2.26.2

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


[PATCH RFT/RFC 46/49] staging: media: zoran: fix some compliance test

2020-09-21 Thread Corentin Labbe
Add TODO for "TRY_FMT cannot handle an invalid pixelformat"

We need to set pixelformat in some case.
We should also handle some minimum requirement.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_driver.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 47f397ff190f..4299578c9bb5 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1206,9 +1206,12 @@ static int zoran_try_fmt_vid_cap(struct file *file, void 
*__fh,
if (zoran_formats[i].fourcc == fmt->fmt.pix.pixelformat)
break;
 
-   if (i == NUM_FORMATS)
+   if (i == NUM_FORMATS) {
+   /* TODO do not return here to fix the TRY_FMT cannot handle an 
invalid pixelformat*/
return -EINVAL;
+   }
 
+   fmt->fmt.pix.pixelformat = zoran_formats[i].fourcc;
fmt->fmt.pix.colorspace = zoran_formats[i].colorspace;
if (BUZ_MAX_HEIGHT < (fmt->fmt.pix.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;
@@ -1318,6 +1321,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
if (i == NUM_FORMATS) {
pci_err(zr->pci_dev, "VIDIOC_S_FMT - unknown/unsupported format 
0x%x\n",
fmt->fmt.pix.pixelformat);
+   /* TODO do not return here to fix the TRY_FMT cannot handle an 
invalid pixelformat*/
return -EINVAL;
}
 
@@ -1327,10 +1331,16 @@ static int zoran_s_fmt_vid_cap(struct file *file, void 
*__fh, struct v4l2_format
res = -EBUSY;
return res;
}
+
+   fmt->fmt.pix.pixelformat = zoran_formats[i].fourcc;
if (fmt->fmt.pix.height > BUZ_MAX_HEIGHT)
fmt->fmt.pix.height = BUZ_MAX_HEIGHT;
if (fmt->fmt.pix.width > BUZ_MAX_WIDTH)
fmt->fmt.pix.width = BUZ_MAX_WIDTH;
+   if (fmt->fmt.pix.height < BUZ_MIN_HEIGHT)
+   fmt->fmt.pix.height = BUZ_MIN_HEIGHT;
+   if (fmt->fmt.pix.width < BUZ_MIN_WIDTH)
+   fmt->fmt.pix.width = BUZ_MIN_WIDTH;
 
map_mode_raw(fh);
 
-- 
2.26.2

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


[PATCH RFT/RFC 30/49] staging: media: zoran: use devm for videocodec_master alloc

2020-09-21 Thread Corentin Labbe
Let's use devm allocations for videocodec, this simplify code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 62e63804ae14..756b9a339f7e 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -989,18 +989,10 @@ static void zoran_remove(struct pci_dev *pdev)
goto exit_free;
 
/* unregister videocodec bus */
-   if (zr->codec) {
-   struct videocodec_master *master = zr->codec->master_data;
-
+   if (zr->codec)
videocodec_detach(zr->codec);
-   kfree(master);
-   }
-   if (zr->vfe) {
-   struct videocodec_master *master = zr->vfe->master_data;
-
+   if (zr->vfe)
videocodec_detach(zr->vfe);
-   kfree(master);
-   }
 
/* unregister i2c bus */
zoran_unregister_i2c(zr);
@@ -1028,7 +1020,7 @@ static struct videocodec_master 
*zoran_setup_videocodec(struct zoran *zr, int ty
 {
struct videocodec_master *m = NULL;
 
-   m = kmalloc(sizeof(*m), GFP_KERNEL);
+   m = devm_kmalloc(>pci_dev->dev, sizeof(*m), GFP_KERNEL);
if (!m)
return m;
 
@@ -1234,7 +1226,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zr->codec = videocodec_attach(master_codec);
if (!zr->codec) {
pci_err(pdev, "%s - no codec found\n", __func__);
-   goto zr_free_codec;
+   goto zr_unreg_i2c;
}
if (zr->codec->type != zr->card.video_codec) {
pci_err(pdev, "%s - wrong codec\n", __func__);
@@ -1248,7 +1240,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zr->vfe = videocodec_attach(master_vfe);
if (!zr->vfe) {
pci_err(pdev, "%s - no VFE found\n", __func__);
-   goto zr_free_vfe;
+   goto zr_detach_codec;
}
if (zr->vfe->type != zr->card.video_vfe) {
pci_err(pdev, "%s = wrong VFE\n", __func__);
@@ -1269,12 +1261,8 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
 zr_detach_vfe:
videocodec_detach(zr->vfe);
-zr_free_vfe:
-   kfree(master_vfe);
 zr_detach_codec:
videocodec_detach(zr->codec);
-zr_free_codec:
-   kfree(master_codec);
 zr_unreg_i2c:
zoran_unregister_i2c(zr);
 zr_free_irq:
-- 
2.26.2

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


[PATCH RFT/RFC 07/49] staging: media: zoran: do not forward declare zr36057_init_vfe

2020-09-21 Thread Corentin Labbe
move function for avoiding forward declaration

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 44 +++---
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 783d7bce6c80..0985b16d5a55 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -55,7 +55,27 @@ static bool lml33dpath;  /* default = 0
 module_param(lml33dpath, bool, 0644);
 MODULE_PARM_DESC(lml33dpath, "Use digital path capture mode (on LML33 cards)");
 
-static void zr36057_init_vfe(struct zoran *zr);
+/*
+ * initialize video front end
+ */
+static void zr36057_init_vfe(struct zoran *zr)
+{
+   u32 reg;
+
+   reg = btread(ZR36057_VFESPFR);
+   reg |= ZR36057_VFESPFR_LittleEndian;
+   reg &= ~ZR36057_VFESPFR_VCLKPol;
+   reg |= ZR36057_VFESPFR_ExtFl;
+   reg |= ZR36057_VFESPFR_TopField;
+   btwrite(reg, ZR36057_VFESPFR);
+   reg = btread(ZR36057_VDCR);
+   if (pci_pci_problems & PCIPCI_TRITON)
+   // || zr->revision < 1) // Revision 1 has also Triton support
+   reg &= ~ZR36057_VDCR_Triton;
+   else
+   reg |= ZR36057_VDCR_Triton;
+   btwrite(reg, ZR36057_VDCR);
+}
 
 /*
  * General Purpose I/O and Guest bus access
@@ -1474,25 +1494,3 @@ void zr36057_restart(struct zoran *zr)
btwrite((0x81 << 24) | 0x, ZR36057_GPPGCR1);
 }
 
-/*
- * initialize video front end
- */
-
-static void zr36057_init_vfe(struct zoran *zr)
-{
-   u32 reg;
-
-   reg = btread(ZR36057_VFESPFR);
-   reg |= ZR36057_VFESPFR_LittleEndian;
-   reg &= ~ZR36057_VFESPFR_VCLKPol;
-   reg |= ZR36057_VFESPFR_ExtFl;
-   reg |= ZR36057_VFESPFR_TopField;
-   btwrite(reg, ZR36057_VFESPFR);
-   reg = btread(ZR36057_VDCR);
-   if (pci_pci_problems & PCIPCI_TRITON)
-   // || zr->revision < 1) // Revision 1 has also Triton support
-   reg &= ~ZR36057_VDCR_Triton;
-   else
-   reg |= ZR36057_VDCR_Triton;
-   btwrite(reg, ZR36057_VDCR);
-}
-- 
2.26.2

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


[PATCH RFT/RFC 27/49] staging: media: zoran: convert irq to pci irq

2020-09-21 Thread Corentin Labbe
This patch convert zoran to pci_irq functions.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 1c587ce0d8c0..fe4d34e388b4 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1008,7 +1008,7 @@ static void zoran_remove(struct pci_dev *pdev)
zoran_set_pci_master(zr, 0);
/* put chip into reset */
btwrite(0, ZR36057_SPGPPCR);
-   free_irq(zr->pci_dev->irq, zr);
+   pci_free_irq(zr->pci_dev, 0, zr);
/* unmap and free memory */
dma_free_coherent(>pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), 
zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem);
@@ -1166,8 +1166,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto zr_unreg;
}
 
-   result = request_irq(zr->pci_dev->irq, zoran_irq,
-IRQF_SHARED, ZR_DEVNAME(zr), zr);
+   result = pci_request_irq(pdev, 0, zoran_irq, NULL, zr, ZR_DEVNAME(zr));
if (result < 0) {
if (result == -EINVAL) {
pci_err(pdev, "%s - bad IRQ number or handler\n", 
__func__);
@@ -1281,7 +1280,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
zoran_unregister_i2c(zr);
 zr_free_irq:
btwrite(0, ZR36057_SPGPPCR);
-   free_irq(zr->pci_dev->irq, zr);
+   pci_free_irq(zr->pci_dev, 0, zr);
 zr_unmap:
iounmap(zr->zr36057_mem);
 zr_unreg:
-- 
2.26.2

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


[PATCH RFT/RFC 11/49] staging: media: zoran: convert dprintk debug

2020-09-21 Thread Corentin Labbe
This patch convert dprintk(debug) to pci_dbg.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 30 --
 drivers/staging/media/zoran/zoran_card.h   |  6 -
 drivers/staging/media/zoran/zoran_device.c |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 28 
 4 files changed, 21 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index fd633265761c..5a3fa5fe32b1 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -203,7 +203,7 @@ void zr36016_write(struct videocodec *codec, u16 reg, u32 
val)
 
 static void dc10_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
/* Pixel clock selection */
GPIO(zr, 4, 0);
@@ -214,12 +214,12 @@ static void dc10_init(struct zoran *zr)
 
 static void dc10plus_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 }
 
 static void buz_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
/* some stuff from Iomega */
pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15);
@@ -229,7 +229,7 @@ static void buz_init(struct zoran *zr)
 
 static void lml33_init(struct zoran *zr)
 {
-   dprintk(3, KERN_DEBUG "%s: %s\n", ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s\n", __func__);
 
GPIO(zr, 2, 1); // Set Composite input/output
 }
@@ -669,15 +669,11 @@ int zoran_check_jpg_settings(struct zoran *zr, struct 
zoran_jpg_settings *settin
 {
int err = 0, err0 = 0;
 
-   dprintk(4,
-   KERN_DEBUG
-   "%s: %s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
-   ZR_DEVNAME(zr), __func__, settings->decimation, 
settings->HorDcm,
+   pci_dbg(zr->pci_dev, "%s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
+   __func__, settings->decimation, settings->HorDcm,
settings->VerDcm, settings->TmpDcm);
-   dprintk(4,
-   KERN_DEBUG
-   "%s: %s - x: %d, y: %d, w: %d, y: %d\n",
-   ZR_DEVNAME(zr), __func__, settings->img_x, settings->img_y,
+   pci_dbg(zr->pci_dev, "%s - x: %d, y: %d, w: %d, y: %d\n", __func__,
+   settings->img_x, settings->img_y,
settings->img_width, settings->img_height);
/* Check decimation, set default values for decimation = 1, 2, 4 */
switch (settings->decimation) {
@@ -707,10 +703,7 @@ int zoran_check_jpg_settings(struct zoran *zr, struct 
zoran_jpg_settings *settin
case 4:
 
if (zr->card.type == DC10_new) {
-   dprintk(1,
-   KERN_DEBUG
-   "%s: %s - HDec by 4 is not supported on the 
DC10\n",
-   ZR_DEVNAME(zr), __func__);
+   pci_dbg(zr->pci_dev, "%s - HDec by 4 is not supported 
on the DC10\n", __func__);
err0++;
break;
}
@@ -1151,10 +1144,7 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
pci_err(pdev, "Unknown card, try specifying card=X 
module parameter\n");
goto zr_unreg;
}
-   dprintk(3,
-   KERN_DEBUG
-   "%s: %s() - card %s detected\n",
-   ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
+   pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__, 
zoran_cards[card_num].name);
} else {
card_num = card[nr];
if (card_num >= NUM_CARDS || card_num < 0) {
diff --git a/drivers/staging/media/zoran/zoran_card.h 
b/drivers/staging/media/zoran/zoran_card.h
index 4af8cb91d03a..8e0d634cb30f 100644
--- a/drivers/staging/media/zoran/zoran_card.h
+++ b/drivers/staging/media/zoran/zoran_card.h
@@ -14,12 +14,6 @@
 
 extern int zr36067_debug;
 
-#define dprintk(num, format, args...) \
-   do { \
-   if (zr36067_debug >= num) \
-   printk(format, ##args); \
-   } while (0)
-
 /* Anybody who uses more than four? */
 #define BUZ_MAX 4
 
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 1f625e1e8477..516a7f18ce7a 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -871,7 +

[PATCH RFT/RFC 04/49] staging: media: zoran: Documentation: fix typo

2020-09-21 Thread Corentin Labbe
Fix some typo in doc.

Signed-off-by: Corentin Labbe 
---
 Documentation/media/v4l-drivers/zoran.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/media/v4l-drivers/zoran.rst 
b/Documentation/media/v4l-drivers/zoran.rst
index a0586514cd8a..2b82b9a47a71 100644
--- a/Documentation/media/v4l-drivers/zoran.rst
+++ b/Documentation/media/v4l-drivers/zoran.rst
@@ -119,7 +119,7 @@ Pinnacle/Miro DC10+
 * Analog Devices adv7176 TV encoder
 
 Drivers to use: videodev, i2c-core, i2c-algo-bit,
-videocodec, sa7110, adv7175, zr36060, zr36067
+videocodec, saa7110, adv7175, zr36060, zr36067
 
 Inputs/outputs: Composite, S-video and Internal
 
@@ -280,7 +280,7 @@ Samsung ks0127 TV decoder
 What the TV encoder can do an what not
 --
 
-The TV encoder are doing the "same" as the decoder, but in the oder direction.
+The TV encoder are doing the "same" as the decoder, but in the other direction.
 You feed them digital data and the generate a Composite or SVHS signal.
 For information about the colorsystems and TV norm take a look in the
 TV decoder section.
-- 
2.26.2

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


[PATCH RFT/RFC 06/49] staging: media: zoran: unsplit lines

2020-09-21 Thread Corentin Labbe
This patch un-split some lines.
Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 27 
 drivers/staging/media/zoran/zoran_device.c | 49 +++---
 drivers/staging/media/zoran/zoran_driver.c | 27 
 3 files changed, 34 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 960257cd43d6..fcf58d69de31 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -652,8 +652,7 @@ static int zoran_register_i2c(struct zoran *zr)
 {
zr->i2c_algo = zoran_i2c_bit_data_template;
zr->i2c_algo.data = zr;
-   strscpy(zr->i2c_adapter.name, ZR_DEVNAME(zr),
-   sizeof(zr->i2c_adapter.name));
+   strscpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), 
sizeof(zr->i2c_adapter.name));
i2c_set_adapdata(>i2c_adapter, >v4l2_dev);
zr->i2c_adapter.algo_data = >i2c_algo;
zr->i2c_adapter.dev.parent = >pci_dev->dev;
@@ -666,8 +665,7 @@ static void zoran_unregister_i2c(struct zoran *zr)
 }
 
 /* Check a zoran_params struct for correctness, insert default params */
-int zoran_check_jpg_settings(struct zoran *zr,
-struct zoran_jpg_settings *settings, int try)
+int zoran_check_jpg_settings(struct zoran *zr, struct zoran_jpg_settings 
*settings, int try)
 {
int err = 0, err0 = 0;
 
@@ -866,13 +864,10 @@ void zoran_open_init_params(struct zoran *zr)
zr->jpg_settings.odd_even = 0;
zr->jpg_settings.jpg_comp.APPn = 0;
zr->jpg_settings.jpg_comp.APP_len = 0;  /* No APPn marker */
-   memset(zr->jpg_settings.jpg_comp.APP_data, 0,
-  sizeof(zr->jpg_settings.jpg_comp.APP_data));
+   memset(zr->jpg_settings.jpg_comp.APP_data, 0, 
sizeof(zr->jpg_settings.jpg_comp.APP_data));
zr->jpg_settings.jpg_comp.COM_len = 0;  /* No COM marker */
-   memset(zr->jpg_settings.jpg_comp.COM_data, 0,
-  sizeof(zr->jpg_settings.jpg_comp.COM_data));
-   zr->jpg_settings.jpg_comp.jpeg_markers =
-   V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT;
+   memset(zr->jpg_settings.jpg_comp.COM_data, 0, 
sizeof(zr->jpg_settings.jpg_comp.COM_data));
+   zr->jpg_settings.jpg_comp.jpeg_markers = V4L2_JPEG_MARKER_DHT | 
V4L2_JPEG_MARKER_DQT;
i = zoran_check_jpg_settings(zr, >jpg_settings, 0);
if (i)
dprintk(1, KERN_ERR "%s: %s internal error\n",
@@ -1059,8 +1054,7 @@ void zoran_vdev_release(struct video_device *vdev)
kfree(vdev);
 }
 
-static struct videocodec_master *zoran_setup_videocodec(struct zoran *zr,
-   int type)
+static struct videocodec_master *zoran_setup_videocodec(struct zoran *zr, int 
type)
 {
struct videocodec_master *m = NULL;
 
@@ -1214,8 +1208,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 * keep general card information, no settings or anything
 */
zr->card = zoran_cards[card_num];
-   snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
-zr->card.name, zr->id);
+   snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]", 
zr->card.name, zr->id);
 
zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
if (!zr->zr36057_mem) {
@@ -1266,14 +1259,12 @@ static int zoran_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto zr_free_irq;
}
 
-   zr->decoder = v4l2_i2c_new_subdev(>v4l2_dev, >i2c_adapter,
- zr->card.i2c_decoder, 0,
+   zr->decoder = v4l2_i2c_new_subdev(>v4l2_dev, >i2c_adapter, 
zr->card.i2c_decoder, 0,
  zr->card.addrs_decoder);
 
if (zr->card.i2c_encoder)
zr->encoder = v4l2_i2c_new_subdev(>v4l2_dev, 
>i2c_adapter,
- zr->card.i2c_encoder, 0,
- zr->card.addrs_encoder);
+ zr->card.i2c_encoder, 0, 
zr->card.addrs_encoder);
 
dprintk(2, KERN_INFO "%s: Initializing videocodec bus...\n", 
ZR_DEVNAME(zr));
 
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index cbacfa4ea2d0..783d7bce6c80 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -679,8 +679,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum 
zoran_codec_mode mode)
 
/* vertical */
btor(ZR36057_VFEVCR_VSPol, ZR36057_VFEVCR);
-   reg = (6 << ZR36057_VSP_VsyncSize) |
- (tvn->Ht &l

[PATCH RFT/RFC 49/49] staging: media: zoran: update TODO

2020-09-21 Thread Corentin Labbe
Update the TODO of the zoran driver

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/TODO | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/TODO b/drivers/staging/media/zoran/TODO
index 54464095d0d7..6992540d3e53 100644
--- a/drivers/staging/media/zoran/TODO
+++ b/drivers/staging/media/zoran/TODO
@@ -1,4 +1,19 @@
-The zoran driver is marked deprecated. It will be removed
-around May 2019 unless someone is willing to update this
-driver to the latest V4L2 frameworks (especially the vb2
-framework).
+
+How to test the zoran driver:
+- RAW capture
+   mplayer tv:///dev/video0 -tv driver=v4l2
+
+- MJPEG capture (compression)
+   mplayer tv:///dev/video0 -tv driver=v4l2:outfmt=mjpeg
+   TODO: need two test for both Dcim path
+
+- MJPEG play (decompression)
+   ffmpeg -i test.avi -vcodec mjpeg -an -f v4l2 /dev/video0
+   Note: only recent ffmpeg has the ability of sending non-raw video via 
v4l2
+
+   The original way of sending video was via mplayer vo_zr/vo_zr2, but it 
does not compile
+   anymore and is a dead end (usage of some old private ffmpeg structures).
+
+TODO
+- fix the v4l compliance "TRY_FMT cannot handle an invalid pixelformat"
+- Filter JPEG data to made output work
-- 
2.26.2

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


[PATCH RFT/RFC 29/49] staging: media: zoran: convert mdelay to udelay

2020-09-21 Thread Corentin Labbe
As asked by checkpath, let's use udelay.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 3a353130afb9..82d522c1a528 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -1315,9 +1315,9 @@ void zoran_init_hardware(struct zoran *zr)
 void zr36057_restart(struct zoran *zr)
 {
btwrite(0, ZR36057_SPGPPCR);
-   mdelay(1);
+   udelay(1000);
btor(ZR36057_SPGPPCR_SoftReset, ZR36057_SPGPPCR);
-   mdelay(1);
+   udelay(1000);
 
/* assert P_Reset */
btwrite(0, ZR36057_JPC);
-- 
2.26.2

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


[PATCH RFT/RFC 13/49] staging: media: zoran: remove proc_fs

2020-09-21 Thread Corentin Labbe
The zoran driver give some debug information in procfs, but this is not
the right place.
So let's remove them, we will use debugfs later.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/Makefile   |   2 +-
 drivers/staging/media/zoran/zoran.h|   5 -
 drivers/staging/media/zoran/zoran_card.c   |   6 -
 drivers/staging/media/zoran/zoran_device.c |   1 -
 drivers/staging/media/zoran/zoran_driver.c |   1 -
 drivers/staging/media/zoran/zoran_procfs.c | 213 -
 drivers/staging/media/zoran/zoran_procfs.h |  32 
 7 files changed, 1 insertion(+), 259 deletions(-)
 delete mode 100644 drivers/staging/media/zoran/zoran_procfs.c
 delete mode 100644 drivers/staging/media/zoran/zoran_procfs.h

diff --git a/drivers/staging/media/zoran/Makefile 
b/drivers/staging/media/zoran/Makefile
index 21ac29a71458..7023158e3892 100644
--- a/drivers/staging/media/zoran/Makefile
+++ b/drivers/staging/media/zoran/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-zr36067-objs   :=  zoran_procfs.o zoran_device.o \
+zr36067-objs   :=  zoran_device.o \
zoran_driver.o zoran_card.o
 
 obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index eac8e49a080f..1b3eceaead5a 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -346,11 +346,6 @@ struct zoran {
struct zoran_buffer_col jpg_buffers;/* MJPEG buffers' info */
 
/* Additional stuff for testing */
-#ifdef CONFIG_PROC_FS
-   struct proc_dir_entry *zoran_proc;
-#else
-   void *zoran_proc;
-#endif
int testing;
int jpeg_error;
int intr_counter_GIRQ1;
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 5a3fa5fe32b1..02af426cf94e 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -38,7 +37,6 @@
 #include "zoran.h"
 #include "zoran_card.h"
 #include "zoran_device.h"
-#include "zoran_procfs.h"
 
 extern const struct zoran_format zoran_formats[];
 
@@ -973,7 +971,6 @@ static int zr36057_init(struct zoran *zr)
encoder_call(zr, video, s_routing, 2, 0, 0);
}
 
-   zr->zoran_proc = NULL;
zr->initialized = 1;
return 0;
 
@@ -1014,7 +1011,6 @@ static void zoran_remove(struct pci_dev *pdev)
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
kfree(zr->stat_com);
-   zoran_proc_cleanup(zr);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev);
@@ -1271,8 +1267,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (zr36057_init(zr) < 0)
goto zr_detach_vfe;
 
-   zoran_proc_init(zr);
-
return 0;
 
 zr_detach_vfe:
diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 03ad3562a807..0fb65fa4a3dd 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -17,7 +17,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 2f6ef995927a..31ed36906204 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -53,7 +53,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include "zoran.h"
diff --git a/drivers/staging/media/zoran/zoran_procfs.c 
b/drivers/staging/media/zoran/zoran_procfs.c
deleted file mode 100644
index 98f9e0103d83..
--- a/drivers/staging/media/zoran/zoran_procfs.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Zoran zr36057/zr36067 PCI controller driver, for the
- * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
- * Media Labs LML33/LML33R10.
- *
- * This part handles the procFS entries (/proc/ZORAN[%d])
- *
- * Copyright (C) 2000 Serguei Miridonov 
- *
- * Currently maintained by:
- *   Ronald Bultje
- *   Laurent Pinchart 
- *   Mailinglist  
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 

[PATCH RFT/RFC 34/49] staging: media: zoran: constify struct tvnorm

2020-09-21 Thread Corentin Labbe
The structure tvnorm could be consified.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/videocodec.h   |  2 +-
 drivers/staging/media/zoran/zoran.h|  4 ++--
 drivers/staging/media/zoran/zoran_card.c   | 24 +++---
 drivers/staging/media/zoran/zoran_device.c |  4 ++--
 drivers/staging/media/zoran/zr36016.c  |  4 ++--
 drivers/staging/media/zoran/zr36050.c  |  4 ++--
 drivers/staging/media/zoran/zr36060.c  |  2 +-
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.h 
b/drivers/staging/media/zoran/videocodec.h
index 553af4ad431e..a049f3c2c68a 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -256,7 +256,7 @@ struct videocodec {
// set compression or decompression (or freeze, stop, standby, etc)
int (*set_mode)(struct videocodec *codec, int mode);
// setup picture size and norm (for the codec's video frontend)
-   int (*set_video)(struct videocodec *codec, struct tvnorm *norm,
+   int (*set_video)(struct videocodec *codec, const struct tvnorm *norm,
 struct vfe_settings *cap, struct vfe_polarity *pol);
// other control commands, also mmap setup etc.
int (*control)(struct videocodec *codec, int type, int size, void 
*data);
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index c73b7e7fd5e1..727ba67afd56 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -227,7 +227,7 @@ struct card_info {
} input[BUZ_MAX_INPUT];
 
v4l2_std_id norms;
-   struct tvnorm *tvn[3];  /* supported TV norms */
+   const struct tvnorm *tvn[3];/* supported TV norms */
 
u32 jpeg_int;   /* JPEG interrupt */
u32 vsync_int;  /* VSYNC interrupt */
@@ -266,7 +266,7 @@ struct zoran {
u8 initialized; /* flag if zoran has been correctly initialized 
*/
int user;   /* number of current users */
struct card_info card;
-   struct tvnorm *timing;
+   const struct tvnorm *timing;
 
unsigned short id;  /* number of this device */
char name[32];  /* name of this device */
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index b841f532e6bb..176ce8a355ba 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -277,24 +277,24 @@ static char *codecid_to_modulename(u16 codecid)
 //  u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
 // };
 
-static struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
-static struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
-static struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
-static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
+static const struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
+static const struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
+static const struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
+static const struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
 
-static struct tvnorm f50ccir601_lml33 = { 864, 720, 75 + 34, 804, 625, 576, 18 
};
-static struct tvnorm f60ccir601_lml33 = { 858, 720, 57 + 34, 788, 525, 480, 16 
};
+static const struct tvnorm f50ccir601_lml33 = { 864, 720, 75 + 34, 804, 625, 
576, 18 };
+static const struct tvnorm f60ccir601_lml33 = { 858, 720, 57 + 34, 788, 525, 
480, 16 };
 
 /* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
-static struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };
-static struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 };
+static const struct tvnorm f50sqpixel_dc10 = { 944, 768, 0, 880, 625, 576, 0 };
+static const struct tvnorm f60sqpixel_dc10 = { 780, 640, 0, 716, 525, 480, 12 
};
 
 /*
  * FIXME: I cannot swap U and V in saa7114, so i do one pixel left shift in 
zoran (75 -> 74)
  * (Maxim Yevtyushkin )
  */
-static struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74 + 54, 804, 625, 576, 
18 };
-static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 54, 788, 525, 480, 
16 };
+static const struct tvnorm f50ccir601_lm33r10 = { 864, 720, 74 + 54, 804, 625, 
576, 18 };
+static const struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 54, 788, 525, 
480, 16 };
 
 /*
  * FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I 
copy Maxim's left
@@ -303,8 +303,8 @@ static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56 + 
54, 788, 525, 480, 16
  * Christer's driver used the unshifted norms, though...
  * /Sam
  */
-static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 };
-static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 };
+static const struct tvnorm f50ccir601_avs6e

[PATCH RFT/RFC 47/49] staging: media: zoran: remove deprecated .vidioc_g_jpegcomp

2020-09-21 Thread Corentin Labbe
This patchs removed the deprecated .vidioc_g_jpegcomp and replace it
with corresponding v4l2_ctrl_ops code.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c   | 22 ++
 drivers/staging/media/zoran/zoran_driver.c | 48 --
 2 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index e4688891d307..ca998fc2 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1056,6 +1056,25 @@ static void zoran_subdev_notify(struct v4l2_subdev *sd, 
unsigned int cmd, void *
GPIO(zr, 7, 1);
 }
 
+static int zoran_video_set_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct zoran *zr = container_of(ctrl->handler, struct zoran, hdl);
+
+   switch (ctrl->id) {
+   case V4L2_CID_JPEG_COMPRESSION_QUALITY:
+   zr->jpg_settings.jpg_comp.quality = ctrl->val;
+   return zoran_check_jpg_settings(zr, >jpg_settings, 0);
+   default:
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = {
+   .s_ctrl = zoran_video_set_ctrl,
+};
+
 /*
  *   Scan for a Buz card (actually for the PCI controller ZR36057),
  *   request the irq and map the io memory
@@ -1096,6 +1115,9 @@ static int zoran_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (v4l2_ctrl_handler_init(>hdl, 10))
goto zr_unreg;
zr->v4l2_dev.ctrl_handler = >hdl;
+   v4l2_ctrl_new_std(>hdl, _video_ctrl_ops,
+ V4L2_CID_JPEG_COMPRESSION_QUALITY, 0,
+ 100, 1, 50);
spin_lock_init(>spinlock);
mutex_init(>lock);
if (pci_enable_device(pdev))
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 4299578c9bb5..8c23bb4f6b71 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1833,52 +1833,6 @@ static int zoran_s_selection(struct file *file, void 
*__fh, struct v4l2_selectio
return res;
 }
 
-static int zoran_g_jpegcomp(struct file *file, void *__fh, struct 
v4l2_jpegcompression *params)
-{
-   struct zoran *zr = video_drvdata(file);
-
-   memset(params, 0, sizeof(*params));
-
-   params->quality = zr->jpg_settings.jpg_comp.quality;
-   params->APPn = zr->jpg_settings.jpg_comp.APPn;
-   memcpy(params->APP_data, zr->jpg_settings.jpg_comp.APP_data,
-  zr->jpg_settings.jpg_comp.APP_len);
-   params->APP_len = zr->jpg_settings.jpg_comp.APP_len;
-   memcpy(params->COM_data, zr->jpg_settings.jpg_comp.COM_data,
-  zr->jpg_settings.jpg_comp.COM_len);
-   params->COM_len = zr->jpg_settings.jpg_comp.COM_len;
-   params->jpeg_markers = zr->jpg_settings.jpg_comp.jpeg_markers;
-
-   return 0;
-}
-
-static int zoran_s_jpegcomp(struct file *file, void *__fh,
-   const struct v4l2_jpegcompression *params)
-{
-   struct zoran_fh *fh = __fh;
-   struct zoran *zr = fh->zr;
-   int res = 0;
-   struct zoran_jpg_settings settings;
-
-   settings = zr->jpg_settings;
-
-   settings.jpg_comp = *params;
-
-   if (fh->buffers.active != ZORAN_FREE) {
-   pci_warn(zr->pci_dev, "VIDIOC_S_JPEGCOMP called while in 
playback/capture mode\n");
-   res = -EBUSY;
-   return res;
-   }
-
-   res = zoran_check_jpg_settings(zr, , 0);
-   if (res)
-   return res;
-   if (!fh->buffers.allocated)
-   zr->buffer_size = zoran_v4l2_calc_bufsize(>jpg_settings);
-   zr->jpg_settings.jpg_comp = settings.jpg_comp;
-   return res;
-}
-
 static __poll_t zoran_poll(struct file *file, poll_table  *wait)
 {
struct zoran_fh *fh = file->private_data;
@@ -2159,8 +2113,6 @@ static const struct v4l2_ioctl_ops zoran_ioctl_ops = {
.vidioc_s_output= zoran_s_output,*/
.vidioc_g_std   = zoran_g_std,
.vidioc_s_std   = zoran_s_std,
-   .vidioc_g_jpegcomp  = zoran_g_jpegcomp,
-   .vidioc_s_jpegcomp  = zoran_s_jpegcomp,
.vidioc_reqbufs = zoran_reqbufs,
.vidioc_querybuf= zoran_querybuf,
.vidioc_qbuf= zoran_qbuf,
-- 
2.26.2

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


[PATCH RFT/RFC 16/49] staging: media: zoran: do not print random guest 0

2020-09-21 Thread Corentin Labbe
The slot 0 of guest is never initialized and so we print later random
data.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 0fb65fa4a3dd..a33de61a5e9b 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -158,6 +158,9 @@ static void dump_guests(struct zoran *zr)
if (zr36067_debug > 2) {
int i, guest[8];
 
+   /* do not print random data */
+   guest[0] = 0;
+
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
guest[i] = post_office_read(zr, i, 0);
 
@@ -170,6 +173,10 @@ void detect_guest_activity(struct zoran *zr)
int timeout, i, j, res, guest[8], guest0[8], change[8][3];
ktime_t t0, t1;
 
+   /* do not print random data */
+   guest[0] = 0;
+   guest0[0] = 0;
+
dump_guests(zr);
pci_info(zr->pci_dev, "Detecting guests activity, please wait...\n");
for (i = 1; i < 8; i++) /* Don't read jpeg codec here */
-- 
2.26.2

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


[PATCH RFT/RFC 14/49] staging: media: zoran: use VFL_TYPE_VIDEO

2020-09-21 Thread Corentin Labbe
The VFL_TYPE_GRABBER type was removed, so let's use the new type.

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 02af426cf94e..34841c12c224 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -957,7 +957,7 @@ static int zr36057_init(struct zoran *zr)
 * another day.
 */
zr->video_dev->vfl_dir = VFL_DIR_M2M;
-   err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, 
video_nr[zr->id]);
+   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
if (err < 0)
goto exit_free;
video_set_drvdata(zr->video_dev, zr);
-- 
2.26.2

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


[PATCH RFT/RFC 00/49] staging: media: bring back zoran driver

2020-09-21 Thread Corentin Labbe
Hello

The zoran driver was removed in 5.3
The main reason of the removing was lack of motivation to convert it to
VB2
Since I need it, I worked on bringing it back.

So the plan to achieve it was:
- clean up the coding style.
- convert old usage/API
- clean unused code
- convert to VB2

I have tried to split a bit the VB2 patch (by adding/removing code in
another patch), but the result is unfortunately still a big patch.

The result of this serie is a working zoran driver.
Furthermore it is now compliant to v4l-compliance.

In the process some old (useless) feature (fbuf, overlay) was removed
for simplifying maintenance.

The zoran hardware support MJPEG decompression, but this feature is
temporarily disabled by this serie.
But basically, this feature was unusable, since the only tool which
permitted to use it was a mplayer option.
But this mplayer option no longer compile (probably since a long time)
and is such a hack (a copy of some private ffmpeg structure) that it is 
unfixable.
Happily, when I started to work on zoran, a patch was posted on ffmpeg
ML which permit it to output non-raw video stream (and so MJPEG for zoran case).
But the zoran hw does not like some part of JPEG header it receives, so
a filter need to be written.
Anyway, this disabling is not a regression, since this feature was not
usable since a long time.

Since the driver was in staging, I targeted staging, but probably the
driver is in a sufficient good shape to target media and bypass staging.

This driver is tested on a DC10+ (on x86). Tests on different hardware
are welcome.

I would like to thanks all people that helped me to achieve this (mostly #v4l)

Regards

Corentin Labbe (49):
  staging: media: Revert "media: zoran: remove deprecated driver"
  MAINTAINERS: change maintainer of the zoran driver
  staging: media: zoran: datasheet is no longer available from zoran.com
  staging: media: zoran: Documentation: fix typo
  staging: media: zoran: fix checkpatch issue
  staging: media: zoran: unsplit lines
  staging: media: zoran: do not forward declare zr36057_init_vfe
  staging: media: zoran: convert all error dprintk to pci_err/pr_err
  staging: media: zoran: convert dprintk warn
  staging: media: zoran: convert dprintk info to pci_info
  staging: media: zoran: convert dprintk debug
  staging: media: zoran: zoran_device.c: convert pr_x to pci_x
  staging: media: zoran: remove proc_fs
  staging: media: zoran: use VFL_TYPE_VIDEO
  staging: media: zoran: use v4l2_buffer_set_timestamp
  staging: media: zoran: do not print random guest 0
  staging: media: zoran: move buffer_size out of zoran_fh
  staging: media: zoran: move v4l_settings out of zoran_fh
  staging: media: zoran: move jpg_settings out of zoran_fh
  staging: media: zoran: move overlay_settings out of zoran_fh
  staging: media: zoran: Use video_drvdata to get struct zoran
  staging: media: zoran: Change zoran_v4l_set_format parameter from
zoran_fh to zoran
  staging: media: zoran: remove overlay
  staging: media: zoran: Use DMA coherent for stat_com
  staging: media: zoran: use ZR_NORM
  staging: media: zoran: zoran does not support STD_ALL
  staging: media: zoran: convert irq to pci irq
  staging: media: zoran: convert zoran alloc to devm
  staging: media: zoran: convert mdelay to udelay
  staging: media: zoran: use devm for videocodec_master alloc
  staging: media: zoran: use pci_request_regions
  staging: media: zoran: use devm_ioremap
  staging: media: zoran: add stat_com buffer
  staging: media: zoran: constify struct tvnorm
  staging: media: zoran: constify codec_name
  staging: media: zoran: Add more check for compliance
  staging: media: zoran: add fallthrough keyword
  staging: media: zoran: Add vb_queue
  staging: media: zoran: disable output
  staging: media: zoran: device support only 32bit DMA address
  staging: media: zoran: enable makefile
  staging: media: zoran: remove framebuffer support
  staging: media: zoran: add vidioc_g_parm
  staging: media: zoran: remove test_interrupts
  staging: media: zoran: fix use of buffer_size and sizeimage
  staging: media: zoran: fix some compliance test
  staging: media: zoran: remove deprecated .vidioc_g_jpegcomp
  staging: media: zoran: convert to vb2
  staging: media: zoran: update TODO

 Documentation/media/v4l-drivers/zoran.rst  |  575 +
 MAINTAINERS|   10 +
 drivers/staging/media/Kconfig  |2 +
 drivers/staging/media/Makefile |1 +
 drivers/staging/media/zoran/Kconfig|   76 ++
 drivers/staging/media/zoran/Makefile   |7 +
 drivers/staging/media/zoran/TODO   |   19 +
 drivers/staging/media/zoran/videocodec.c   |  330 +
 drivers/staging/media/zoran/videocodec.h   |  308 +
 drivers/staging/media/zoran/zoran.h|  320 +
 drivers/staging/media/zoran/zoran_card.c   | 1320 
 drivers/staging/media/zoran/zoran_card.h   |   30 +
 drivers/staging/media/zoran/zoran_devic

[PATCH RFT/RFC 03/49] staging: media: zoran: datasheet is no longer available from zoran.com

2020-09-21 Thread Corentin Labbe
Simply remove this broken reference

Signed-off-by: Corentin Labbe 
---
 drivers/staging/media/zoran/zoran_device.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 04162be80420..79da964c678b 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -265,9 +265,6 @@ jpeg_codec_reset (struct zoran *zr)
  *   Set the registers for the size we have specified. Don't bother
  *   trying to understand this without the ZR36057 manual in front of
  *   you [AC].
- *
- *   PS: The manual is free for download in .pdf format from
- *   www.zoran.com - nicely done those folks.
  */
 
 static void
-- 
2.26.2

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


Re: [linux-sunxi] [PATCH v8 3/8] dt-bindings: media: Document bindings for the Cedrus VPU driver

2018-08-28 Thread Corentin Labbe
On Tue, Aug 28, 2018 at 09:34:19AM +0200, Paul Kocialkowski wrote:
> This adds a device-tree binding document that specifies the properties
> used by the Cedurs VPU driver, as well as examples.

typo Cedurs=>Cedrus

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


[PATCH] staging: media: atomisp: Remove inclusion of non-existing directories

2018-02-22 Thread Corentin Labbe
This patch fix the following build warnings:
  CC [M]  drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.o
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/bayer_ls/bayer_ls_1.0/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/io_ls/plane_io_ls/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/io_ls/yuv420_io_ls/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/ipu2_io_ls/plane_io_ls/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/ipu2_io_ls/yuv420_io_ls/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/s3a_stat_ls/: No 
such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/scale/: No such 
file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/scale/scale_1.0/:
 No such file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/yuv_ls: No such 
file or directory [-Wmissing-include-dirs]
cc1: warning: 
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/yuv_ls/yuv_ls_1.0/:
 No such file or directory [-Wmissing-include-dirs]
by removing the inclusion of such directories

Signed-off-by: Corentin Labbe <cla...@baylibre.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/Makefile | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/Makefile 
b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
index ac3805345f20..83f816faba1b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/Makefile
+++ b/drivers/staging/media/atomisp/pci/atomisp2/Makefile
@@ -215,7 +215,6 @@ INCLUDES += \
-I$(atomisp)/css2400/isp/kernels/aa/aa_2/ \
-I$(atomisp)/css2400/isp/kernels/anr/anr_1.0/ \
-I$(atomisp)/css2400/isp/kernels/anr/anr_2/ \
-   -I$(atomisp)/css2400/isp/kernels/bayer_ls/bayer_ls_1.0/ \
-I$(atomisp)/css2400/isp/kernels/bh/bh_2/ \
-I$(atomisp)/css2400/isp/kernels/bnlm/ \
-I$(atomisp)/css2400/isp/kernels/bnr/ \
@@ -258,14 +257,10 @@ INCLUDES += \
-I$(atomisp)/css2400/isp/kernels/io_ls/ \
-I$(atomisp)/css2400/isp/kernels/io_ls/bayer_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/io_ls/common/ \
-   -I$(atomisp)/css2400/isp/kernels/io_ls/plane_io_ls/ \
-   -I$(atomisp)/css2400/isp/kernels/io_ls/yuv420_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/io_ls/yuv444_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/bayer_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/common/ \
-   -I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/plane_io_ls/ \
-   -I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/yuv420_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/yuv444_io_ls/ \
-I$(atomisp)/css2400/isp/kernels/iterator/ \
-I$(atomisp)/css2400/isp/kernels/iterator/iterator_1.0/ \
@@ -289,9 +284,6 @@ INCLUDES += \
-I$(atomisp)/css2400/isp/kernels/ref/ref_1.0/ \
-I$(atomisp)/css2400/isp/kernels/s3a/ \
-I$(atomisp)/css2400/isp/kernels/s3a/s3a_1.0/ \
-   -I$(atomisp)/css2400/isp/kernels/s3a_stat_ls/ \
-   -I$(atomisp)/css2400/isp/kernels/scale/ \
-   -I$(atomisp)/css2400/isp/kernels/scale/scale_1.0/ \
-I$(atomisp)/css2400/isp/kernels/sc/ \
-I$(atomisp)/css2400/isp/kernels/sc/sc_1.0/ \
-I$(atomisp)/css2400/isp/kernels/sdis/ \
@@ -315,8 +307,6 @@ INCLUDES += \
-I$(atomisp)/css2400/isp/kernels/ynr/ \
-I$(atomisp)/css2400/isp/kernels/ynr/ynr_1.0/ \
-I$(atomisp)/css2400/isp/kernels/ynr/ynr_2/ \
-   -I$(atomisp)/css2400/isp/kernels/yuv_ls \
-   -I$(atomisp)/css2400/isp/kernels/yuv_ls/yuv_ls_1.0/ \
-I$(atomisp)/css2400/isp/modes/interface/ \
-I$(atomisp)/css2400/runtime/binary/interface/ \
-I$(atomisp)/css2400/runtime/bufq/interface/ \
-- 
2.16.1

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


[PATCH] staging: vc04_services: remove unused files

2018-02-01 Thread Corentin Labbe
All thoses files are not used by anybody.
Lets just remove them.

Signed-off-by: Corentin Labbe <cla...@baylibre.com>
---
 .../interface/vchiq_arm/vchiq_build_info.h | 37 --
 .../interface/vchiq_arm/vchiq_memdrv.h | 59 --
 .../interface/vchiq_arm/vchiq_version.c| 59 --
 3 files changed, 155 deletions(-)
 delete mode 100644 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_build_info.h
 delete mode 100644 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_memdrv.h
 delete mode 100644 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_version.c

diff --git 
a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_build_info.h 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_build_info.h
deleted file mode 100644
index df645813bdae..
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_build_info.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2010-2012 Broadcom. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions, and the following disclaimer,
- *without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. The names of the above-listed copyright holders may not be used
- *to endorse or promote products derived from this software without
- *specific prior written permission.
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2, as published by the Free
- * Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-const char *vchiq_get_build_hostname(void);
-const char *vchiq_get_build_version(void);
-const char *vchiq_get_build_time(void);
-const char *vchiq_get_build_date(void);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_memdrv.h 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_memdrv.h
deleted file mode 100644
index c233b866725b..
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_memdrv.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2010-2012 Broadcom. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions, and the following disclaimer,
- *without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. The names of the above-listed copyright holders may not be used
- *to endorse or promote products derived from this software without
- *specific prior written permission.
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2, as published by the Free
- * Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF

[PATCH] staging: fbtft: remove unused FB_TFT_SSD1325 kconfig

2018-01-23 Thread Corentin Labbe
Since nothing builds/depends on FB_TFT_SSD1325, we could remove it.

Signed-off-by: Corentin Labbe <cla...@baylibre.com>
---
 drivers/staging/fbtft/Kconfig | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig
index dba676761d72..84b2e7ebc024 100644
--- a/drivers/staging/fbtft/Kconfig
+++ b/drivers/staging/fbtft/Kconfig
@@ -135,12 +135,6 @@ config FB_TFT_SSD1306
help
  Framebuffer support for SSD1306
 
-config FB_TFT_SSD1325
-tristate "FB driver for the SSD1325 OLED Controller"
-depends on FB_TFT
-help
-  Framebuffer support for SSD1305
-
 config FB_TFT_SSD1331
tristate "FB driver for the SSD1331 LCD Controller"
depends on FB_TFT
-- 
2.13.6

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


[PATCH] staging: media: remove unused VIDEO_ATOMISP_OV8858 kconfig

2018-01-23 Thread Corentin Labbe
Nothing in kernel use VIDEO_ATOMISP_OV8858 since commit 3a81c7660f80 ("media: 
staging: atomisp: Remove IMX sensor support")
Lets remove this kconfig option.

Signed-off-by: Corentin Labbe <cla...@baylibre.com>
---
 drivers/staging/media/atomisp/i2c/Kconfig | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/Kconfig 
b/drivers/staging/media/atomisp/i2c/Kconfig
index db054d3c7ed6..f7f7177b9b37 100644
--- a/drivers/staging/media/atomisp/i2c/Kconfig
+++ b/drivers/staging/media/atomisp/i2c/Kconfig
@@ -28,18 +28,6 @@ config VIDEO_ATOMISP_GC2235
 
 It currently only works with the atomisp driver.
 
-config VIDEO_ATOMISP_OV8858
-   tristate "Omnivision ov8858 sensor support"
-   depends on ACPI
-   depends on I2C && VIDEO_V4L2 && VIDEO_ATOMISP
-   ---help---
-This is a Video4Linux2 sensor-level driver for the Omnivision
-ov8858 RAW sensor.
-
-OV8858 is a 8M raw sensor.
-
-It currently only works with the atomisp driver.
-
 config VIDEO_ATOMISP_MSRLIST_HELPER
tristate "Helper library to load, parse and apply large register lists."
depends on I2C
-- 
2.13.6

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


[PATCH] staging: rtlwifi: remove unused RTLHALMAC_ST and RTLPHYDM_ST

2018-01-23 Thread Corentin Labbe
Since nothing builds/depends on RTLHALMAC_ST and RTLPHYDM_ST, we could
remove them.
Furthermore, they are totally undocumented

Signed-off-by: Corentin Labbe <cla...@baylibre.com>
---
 drivers/staging/rtlwifi/Kconfig | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/staging/rtlwifi/Kconfig b/drivers/staging/rtlwifi/Kconfig
index 12cf4675b5fd..7b4276f5c41f 100644
--- a/drivers/staging/rtlwifi/Kconfig
+++ b/drivers/staging/rtlwifi/Kconfig
@@ -6,16 +6,6 @@ config R8822BE
This is the staging driver for Realtek RTL8822BE 802.11ac PCIe
wireless network adapters.
 
-config RTLHALMAC_ST
-   tristate
-   depends on R8822BE
-   default m
-
-config RTLPHYDM_ST
-   tristate
-   depends on R8822BE
-   default m
-
 config RTLWIFI_DEBUG_ST
bool
depends on R8822BE
-- 
2.13.6

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


  1   2   >