All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] staging: media: zoran: fusion in one module
@ 2021-09-03 19:15 Corentin Labbe
  2021-09-03 19:15 ` [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe Corentin Labbe
                   ` (8 more replies)
  0 siblings, 9 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

Hello

The main change of this serie is to fusion all zoran related modules in
one.
This fixes the load order problem when everything is built-in.

Regards

Corentin Labbe (8):
  staging: media: zoran: move module parameter checks to zoran_probe
  staging: media: zoran: use module_pci_driver
  staging: media: zoran: rename debug module parameter
  staging: media: zoran: add debugfs
  staging: media: zoran: videocode: remove procfs
  staging: media: zoran: fusion all modules
  staging: media: zoran: remove vidmem
  staging: media: zoran: move videodev alloc

 drivers/staging/media/zoran/Kconfig        |  24 +-
 drivers/staging/media/zoran/Makefile       |   8 +-
 drivers/staging/media/zoran/videocodec.c   |  60 +----
 drivers/staging/media/zoran/videocodec.h   |   5 +
 drivers/staging/media/zoran/zoran.h        |   7 +-
 drivers/staging/media/zoran/zoran_card.c   | 259 +++++++++++++--------
 drivers/staging/media/zoran/zoran_driver.c |   5 +-
 drivers/staging/media/zoran/zr36016.c      |  23 +-
 drivers/staging/media/zoran/zr36016.h      |   2 +
 drivers/staging/media/zoran/zr36050.c      |  20 +-
 drivers/staging/media/zoran/zr36050.h      |   2 +
 drivers/staging/media/zoran/zr36060.c      |  20 +-
 drivers/staging/media/zoran/zr36060.h      |   2 +
 13 files changed, 229 insertions(+), 208 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 19:15 ` [PATCH 2/8] staging: media: zoran: use module_pci_driver Corentin Labbe
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

We need to empty zoran_init() for removing it later.
Furthermore, this permit to use pci_xxx instead of pr_xxx for prettier
printing.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/zoran_card.c | 64 ++++++++++++------------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
index f259585b0689..3bc0e64f1007 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1067,6 +1067,39 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	unsigned int nr;
 	int err;
 
+	pci_info(pdev, "Zoran MJPEG board driver version %s\n", ZORAN_VERSION);
+
+	/* check the parameters we have been given, adjust if necessary */
+	if (v4l_nbufs < 2)
+		v4l_nbufs = 2;
+	if (v4l_nbufs > VIDEO_MAX_FRAME)
+		v4l_nbufs = VIDEO_MAX_FRAME;
+	/* The user specifies the in KB, we want them in byte (and page aligned) */
+	v4l_bufsize = PAGE_ALIGN(v4l_bufsize * 1024);
+	if (v4l_bufsize < 32768)
+		v4l_bufsize = 32768;
+	/* 2 MB is arbitrary but sufficient for the maximum possible images */
+	if (v4l_bufsize > 2048 * 1024)
+		v4l_bufsize = 2048 * 1024;
+	if (jpg_nbufs < 4)
+		jpg_nbufs = 4;
+	if (jpg_nbufs > BUZ_MAX_FRAME)
+		jpg_nbufs = BUZ_MAX_FRAME;
+	jpg_bufsize = PAGE_ALIGN(jpg_bufsize * 1024);
+	if (jpg_bufsize < 8192)
+		jpg_bufsize = 8192;
+	if (jpg_bufsize > (512 * 1024))
+		jpg_bufsize = 512 * 1024;
+	/* Use parameter for vidmem or try to find a video card */
+	if (vidmem)
+		pci_info(pdev, "%s: Using supplied video memory base address @ 0x%lx\n",
+			 ZORAN_NAME, vidmem);
+
+	/* some mainboards might not do PCI-PCI data transfer well */
+	if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
+		pci_warn(pdev, "%s: chipset does not support reliable PCI-PCI DMA\n",
+			 ZORAN_NAME);
+
 	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 	if (err)
 		return -ENODEV;
@@ -1285,37 +1318,6 @@ static int __init zoran_init(void)
 {
 	int res;
 
-	pr_info("Zoran MJPEG board driver version %s\n", ZORAN_VERSION);
-
-	/* check the parameters we have been given, adjust if necessary */
-	if (v4l_nbufs < 2)
-		v4l_nbufs = 2;
-	if (v4l_nbufs > VIDEO_MAX_FRAME)
-		v4l_nbufs = VIDEO_MAX_FRAME;
-	/* The user specifies the in KB, we want them in byte (and page aligned) */
-	v4l_bufsize = PAGE_ALIGN(v4l_bufsize * 1024);
-	if (v4l_bufsize < 32768)
-		v4l_bufsize = 32768;
-	/* 2 MB is arbitrary but sufficient for the maximum possible images */
-	if (v4l_bufsize > 2048 * 1024)
-		v4l_bufsize = 2048 * 1024;
-	if (jpg_nbufs < 4)
-		jpg_nbufs = 4;
-	if (jpg_nbufs > BUZ_MAX_FRAME)
-		jpg_nbufs = BUZ_MAX_FRAME;
-	jpg_bufsize = PAGE_ALIGN(jpg_bufsize * 1024);
-	if (jpg_bufsize < 8192)
-		jpg_bufsize = 8192;
-	if (jpg_bufsize > (512 * 1024))
-		jpg_bufsize = 512 * 1024;
-	/* Use parameter for vidmem or try to find a video card */
-	if (vidmem)
-		pr_info("%s: Using supplied video memory base address @ 0x%lx\n", ZORAN_NAME, vidmem);
-
-	/* some mainboards might not do PCI-PCI data transfer well */
-	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(&zoran_driver);
 	if (res) {
 		pr_err("Unable to register ZR36057 driver\n");
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/8] staging: media: zoran: use module_pci_driver
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
  2021-09-03 19:15 ` [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 19:15 ` [PATCH 3/8] staging: media: zoran: rename debug module parameter Corentin Labbe
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

Simplify code by using module_pci_driver()

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/zoran_card.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
index 3bc0e64f1007..f1465fbf98af 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1314,23 +1314,4 @@ static struct pci_driver zoran_driver = {
 	.remove = zoran_remove,
 };
 
-static int __init zoran_init(void)
-{
-	int res;
-
-	res = pci_register_driver(&zoran_driver);
-	if (res) {
-		pr_err("Unable to register ZR36057 driver\n");
-		return res;
-	}
-
-	return 0;
-}
-
-static void __exit zoran_exit(void)
-{
-	pci_unregister_driver(&zoran_driver);
-}
-
-module_init(zoran_init);
-module_exit(zoran_exit);
+module_pci_driver(zoran_driver);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/8] staging: media: zoran: rename debug module parameter
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
  2021-09-03 19:15 ` [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe Corentin Labbe
  2021-09-03 19:15 ` [PATCH 2/8] staging: media: zoran: use module_pci_driver Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

All zoran module will be merged, so to prevent conflict, the debug
module parameter need to be renamed

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/videocodec.c |  8 ++++----
 drivers/staging/media/zoran/zr36016.c    | 12 ++++++------
 drivers/staging/media/zoran/zr36050.c    |  8 ++++----
 drivers/staging/media/zoran/zr36060.c    |  9 ++++-----
 4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.c b/drivers/staging/media/zoran/videocodec.c
index 28031d3fd757..31019b5f377e 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -26,13 +26,13 @@
 
 #include "videocodec.h"
 
-static int debug;
-module_param(debug, int, 0);
-MODULE_PARM_DESC(debug, "Debug level (0-4)");
+static int videocodec_debug;
+module_param(videocodec_debug, int, 0);
+MODULE_PARM_DESC(videocodec_debug, "Debug level (0-4)");
 
 #define dprintk(num, format, args...) \
 	do { \
-		if (debug >= num) \
+		if (videocodec_debug >= num) \
 			printk(format, ##args); \
 	} while (0)
 
diff --git a/drivers/staging/media/zoran/zr36016.c b/drivers/staging/media/zoran/zr36016.c
index 9b350a885879..50605460a44b 100644
--- a/drivers/staging/media/zoran/zr36016.c
+++ b/drivers/staging/media/zoran/zr36016.c
@@ -22,14 +22,14 @@
 /* amount of chips attached via this driver */
 static int zr36016_codecs;
 
-/* debugging is available via module parameter */
-static int debug;
-module_param(debug, int, 0);
-MODULE_PARM_DESC(debug, "Debug level (0-4)");
+static int zr36016_debug;
+module_param(zr36016_debug, int, 0);
+MODULE_PARM_DESC(zr36016_debug, "Debug level (0-4)");
+
 
 #define dprintk(num, format, args...) \
 	do { \
-		if (debug >= num) \
+		if (zr36016_debug >= num) \
 			printk(format, ##args); \
 	} while (0)
 
@@ -120,7 +120,7 @@ static u8 zr36016_read_version(struct zr36016 *ptr)
 
 static int zr36016_basic_test(struct zr36016 *ptr)
 {
-	if (debug) {
+	if (zr36016_debug) {
 		int i;
 
 		zr36016_writei(ptr, ZR016I_PAX_LO, 0x55);
diff --git a/drivers/staging/media/zoran/zr36050.c b/drivers/staging/media/zoran/zr36050.c
index c62af27f2683..4dc7927fefc3 100644
--- a/drivers/staging/media/zoran/zr36050.c
+++ b/drivers/staging/media/zoran/zr36050.c
@@ -32,13 +32,13 @@
 static int zr36050_codecs;
 
 /* debugging is available via module parameter */
-static int debug;
-module_param(debug, int, 0);
-MODULE_PARM_DESC(debug, "Debug level (0-4)");
+static int zr36050_debug;
+module_param(zr36050_debug, int, 0);
+MODULE_PARM_DESC(zr36050_debug, "Debug level (0-4)");
 
 #define dprintk(num, format, args...) \
 	do { \
-		if (debug >= num) \
+		if (zr36050_debug >= num) \
 			printk(format, ##args); \
 	} while (0)
 
diff --git a/drivers/staging/media/zoran/zr36060.c b/drivers/staging/media/zoran/zr36060.c
index 1c3af11b5f24..7904d5b1f402 100644
--- a/drivers/staging/media/zoran/zr36060.c
+++ b/drivers/staging/media/zoran/zr36060.c
@@ -34,14 +34,13 @@ static bool low_bitrate;
 module_param(low_bitrate, bool, 0);
 MODULE_PARM_DESC(low_bitrate, "Buz compatibility option, halves bitrate");
 
-/* debugging is available via module parameter */
-static int debug;
-module_param(debug, int, 0);
-MODULE_PARM_DESC(debug, "Debug level (0-4)");
+static int zr36060_debug;
+module_param(zr36060_debug, int, 0);
+MODULE_PARM_DESC(zr36060_debug, "Debug level (0-4)");
 
 #define dprintk(num, format, args...) \
 	do { \
-		if (debug >= num) \
+		if (zr36060_debug >= num) \
 			printk(format, ##args); \
 	} while (0)
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (2 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 3/8] staging: media: zoran: rename debug module parameter Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 23:28     ` kernel test robot
                     ` (3 more replies)
  2021-09-03 19:15 ` [PATCH 5/8] staging: media: zoran: videocode: remove procfs Corentin Labbe
                   ` (4 subsequent siblings)
  8 siblings, 4 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

Add debugfs for displaying zoran debug and stats information.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/Kconfig      | 10 ++++++
 drivers/staging/media/zoran/zoran.h      |  5 +++
 drivers/staging/media/zoran/zoran_card.c | 39 ++++++++++++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig
index 7874842033ca..7d2d3c2431b1 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -74,3 +74,13 @@ config VIDEO_ZORAN_AVS6EYES
 	select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT
 	help
 	  Support for the AverMedia 6 Eyes video surveillance card.
+
+config VIDEO_ZORAN_DEBUG
+	bool "Enable zoran debugfs"
+	depends on VIDEO_ZORAN
+	depends on DEBUG_FS
+	help
+	  Say y to enable zoran debug file.
+	  This will create /sys/kernel/debug/CARD_NAME/debug for displaying
+	  stats and debug information.
+
diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
index b1ad2a2b914c..8c271005f14d 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -18,6 +18,7 @@
 #ifndef _BUZ_H_
 #define _BUZ_H_
 
+#include <linux/debugfs.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
 #include <media/videobuf2-core.h>
@@ -295,6 +296,10 @@ struct zoran {
 	struct list_head queued_bufs;
 	spinlock_t queued_bufs_lock; /* Protects queued_bufs */
 	struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2];
+#ifdef CONFIG_VIDEO_ZORAN_DEBUG
+	struct dentry *dbgfs_dir;
+	struct dentry *dbgfs_file;
+#endif
 };
 
 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 f1465fbf98af..1ed8ed2f4f7f 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -1051,6 +1051,39 @@ static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = {
 	.s_ctrl = zoran_video_set_ctrl,
 };
 
+#ifdef CONFIG_VIDEO_ZORAN_DEBUG
+static int zoran_debugfs_show(struct seq_file *seq, void *v)
+{
+	struct zoran *zr = seq->private;
+
+	seq_printf(seq, "Running mode %x\n", zr->running);
+	seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
+	seq_printf(seq, "Norm %x\n", zr->norm);
+	seq_printf(seq, "Input %d\n", zr->input);
+	seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
+
+	seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
+	seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
+
+	seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
+	seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
+	seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
+	seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
+	seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
+	seq_printf(seq, "JPG crop %dx%d %d %d\n",
+		zr->jpg_settings.img_x,
+		zr->jpg_settings.img_y,
+		zr->jpg_settings.img_width,
+		zr->jpg_settings.img_height);
+
+	seq_printf(seq, "Prepared %u\n", zr->prepared);
+	seq_printf(seq, "Queued %u\n", zr->queued);
+	return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(zoran_debugfs);
+#endif
+
 /*
  *   Scan for a Buz card (actually for the PCI controller ZR36057),
  *   request the irq and map the io memory
@@ -1286,6 +1319,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	zr->map_mode = ZORAN_MAP_MODE_RAW;
 
+#ifdef CONFIG_VIDEO_ZORAN_DEBUG
+	zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL);
+	zr->dbgfs_file = debugfs_create_file("debug", 0444,
+					      zr->dbgfs_dir, zr,
+					      &zoran_debugfs_fops);
+#endif
 	return 0;
 
 zr_detach_vfe:
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/8] staging: media: zoran: videocode: remove procfs
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (3 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 19:15 ` [PATCH 6/8] staging: media: zoran: fusion all modules Corentin Labbe
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

Now we have a debugfs, we can remove all PROCFS stuff.
We keep videocodec_debugfs_show(), it will be used later

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/videocodec.c | 24 ++----------------------
 drivers/staging/media/zoran/videocodec.h |  5 +++++
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.c b/drivers/staging/media/zoran/videocodec.c
index 31019b5f377e..3d5a83a07e07 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -16,14 +16,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 
-// kernel config is here (procfs flag)
-
-#ifdef CONFIG_PROC_FS
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/uaccess.h>
-#endif
-
 #include "videocodec.h"
 
 static int videocodec_debug;
@@ -265,8 +257,8 @@ int videocodec_unregister(const struct videocodec *codec)
 }
 EXPORT_SYMBOL(videocodec_unregister);
 
-#ifdef CONFIG_PROC_FS
-static int proc_videocodecs_show(struct seq_file *m, void *v)
+#ifdef CONFIG_VIDEO_ZORAN_DEBUG
+int videocodec_debugfs_show(struct seq_file *m)
 {
 	struct codec_list *h = codeclist_top;
 	struct attached_list *a;
@@ -300,25 +292,13 @@ static int proc_videocodecs_show(struct seq_file *m, void *v)
 /* ===================== */
 static int __init videocodec_init(void)
 {
-#ifdef CONFIG_PROC_FS
-	static struct proc_dir_entry *videocodec_proc_entry;
-#endif
-
 	pr_info("Linux video codec intermediate layer: %s\n", VIDEOCODEC_VERSION);
 
-#ifdef CONFIG_PROC_FS
-	videocodec_proc_entry = proc_create_single("videocodecs", 0, NULL, proc_videocodecs_show);
-	if (!videocodec_proc_entry)
-		pr_err("videocodec: can't init procfs.\n");
-#endif
 	return 0;
 }
 
 static void __exit videocodec_exit(void)
 {
-#ifdef CONFIG_PROC_FS
-	remove_proc_entry("videocodecs", NULL);
-#endif
 }
 
 module_init(videocodec_init);
diff --git a/drivers/staging/media/zoran/videocodec.h b/drivers/staging/media/zoran/videocodec.h
index 8a5003dda9f4..f2e17566795e 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -123,6 +123,7 @@ M                       zr36055[1] 0001 0000c001 00000000 (zr36050[1])
 #ifndef __LINUX_VIDEOCODEC_H
 #define __LINUX_VIDEOCODEC_H
 
+#include <linux/debugfs.h>
 #include <linux/videodev2.h>
 
 #define CODEC_DO_COMPRESSION 0
@@ -305,4 +306,8 @@ extern int videocodec_unregister(const struct videocodec *);
 
 /* the other calls are directly done via the videocodec structure! */
 
+#ifdef CONFIG_VIDEO_ZORAN_DEBUG
+int videocodec_debugfs_show(struct seq_file *m);
+#endif
+
 #endif				/*ifndef __LINUX_VIDEOCODEC_H */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 6/8] staging: media: zoran: fusion all modules
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (4 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 5/8] staging: media: zoran: videocode: remove procfs Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-06 10:41   ` Hans Verkuil
  2021-09-03 19:15 ` [PATCH 7/8] staging: media: zoran: remove vidmem Corentin Labbe
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

The zoran driver is split in many modules, but this lead to some
problems.
One of them is that load order is incorrect when everything is built-in.

Having more than one module is useless, so fusion all zoran modules in
one.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/Kconfig      | 14 +++----
 drivers/staging/media/zoran/Makefile     |  8 ++--
 drivers/staging/media/zoran/videocodec.c | 28 --------------
 drivers/staging/media/zoran/zoran_card.c | 48 +++++++++++++++++++++---
 drivers/staging/media/zoran/zr36016.c    | 11 +-----
 drivers/staging/media/zoran/zr36016.h    |  2 +
 drivers/staging/media/zoran/zr36050.c    | 12 +-----
 drivers/staging/media/zoran/zr36050.h    |  2 +
 drivers/staging/media/zoran/zr36060.c    | 11 +-----
 drivers/staging/media/zoran/zr36060.h    |  2 +
 10 files changed, 66 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig
index 7d2d3c2431b1..8eacdc00b081 100644
--- a/drivers/staging/media/zoran/Kconfig
+++ b/drivers/staging/media/zoran/Kconfig
@@ -14,7 +14,7 @@ config VIDEO_ZORAN
 	  module will be called zr36067.
 
 config VIDEO_ZORAN_DC30
-	tristate "Pinnacle/Miro DC30(+) support"
+	bool "Pinnacle/Miro DC30(+) support"
 	depends on VIDEO_ZORAN
 	select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_VPX3220 if MEDIA_SUBDRV_AUTOSELECT
@@ -24,7 +24,7 @@ config VIDEO_ZORAN_DC30
 	  zr36050 MJPEG codec and zr36016 VFE.
 
 config VIDEO_ZORAN_ZR36060
-	tristate "Zoran ZR36060"
+	bool "Zoran ZR36060"
 	depends on VIDEO_ZORAN
 	help
 	  Say Y to support Zoran boards based on 36060 chips.
@@ -32,7 +32,7 @@ config VIDEO_ZORAN_ZR36060
 	  and 33 R10 and AverMedia 6 boards.
 
 config VIDEO_ZORAN_BUZ
-	tristate "Iomega Buz support"
+	bool "Iomega Buz support"
 	depends on VIDEO_ZORAN_ZR36060
 	select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_SAA7185 if MEDIA_SUBDRV_AUTOSELECT
@@ -40,7 +40,7 @@ config VIDEO_ZORAN_BUZ
 	  Support for the Iomega Buz MJPEG capture/playback card.
 
 config VIDEO_ZORAN_DC10
-	tristate "Pinnacle/Miro DC10(+) support"
+	bool "Pinnacle/Miro DC10(+) support"
 	depends on VIDEO_ZORAN_ZR36060
 	select VIDEO_SAA7110 if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT
@@ -49,7 +49,7 @@ config VIDEO_ZORAN_DC10
 	  card.
 
 config VIDEO_ZORAN_LML33
-	tristate "Linux Media Labs LML33 support"
+	bool "Linux Media Labs LML33 support"
 	depends on VIDEO_ZORAN_ZR36060
 	select VIDEO_BT819 if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT
@@ -58,7 +58,7 @@ config VIDEO_ZORAN_LML33
 	  card.
 
 config VIDEO_ZORAN_LML33R10
-	tristate "Linux Media Labs LML33R10 support"
+	bool "Linux Media Labs LML33R10 support"
 	depends on VIDEO_ZORAN_ZR36060
 	select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_ADV7170 if MEDIA_SUBDRV_AUTOSELECT
@@ -67,7 +67,7 @@ config VIDEO_ZORAN_LML33R10
 	  card.
 
 config VIDEO_ZORAN_AVS6EYES
-	tristate "AverMedia 6 Eyes support"
+	bool "AverMedia 6 Eyes support"
 	depends on VIDEO_ZORAN_ZR36060
 	select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT
 	select VIDEO_BT866 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/staging/media/zoran/Makefile b/drivers/staging/media/zoran/Makefile
index 7023158e3892..9603bac0195c 100644
--- a/drivers/staging/media/zoran/Makefile
+++ b/drivers/staging/media/zoran/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 zr36067-objs	:=	zoran_device.o \
-			zoran_driver.o zoran_card.o
+			zoran_driver.o zoran_card.o videocodec.o
 
-obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o
-obj-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
-obj-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
+obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o
+zr36067-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
+zr36067-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
diff --git a/drivers/staging/media/zoran/videocodec.c b/drivers/staging/media/zoran/videocodec.c
index 3d5a83a07e07..7350d7747516 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -8,8 +8,6 @@
  * (c) 2002 Wolfgang Scherr <scherr@net4you.at>
  */
 
-#define VIDEOCODEC_VERSION "v0.2"
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -119,7 +117,6 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)
 	kfree(codec);
 	return NULL;
 }
-EXPORT_SYMBOL(videocodec_attach);
 
 int videocodec_detach(struct videocodec *codec)
 {
@@ -175,7 +172,6 @@ int videocodec_detach(struct videocodec *codec)
 	pr_err("%s: given codec not found!\n", __func__);
 	return -EINVAL;
 }
-EXPORT_SYMBOL(videocodec_detach);
 
 int videocodec_register(const struct videocodec *codec)
 {
@@ -208,7 +204,6 @@ int videocodec_register(const struct videocodec *codec)
 
 	return 0;
 }
-EXPORT_SYMBOL(videocodec_register);
 
 int videocodec_unregister(const struct videocodec *codec)
 {
@@ -255,7 +250,6 @@ int videocodec_unregister(const struct videocodec *codec)
 	pr_err("%s: given codec not found!\n", __func__);
 	return -EINVAL;
 }
-EXPORT_SYMBOL(videocodec_unregister);
 
 #ifdef CONFIG_VIDEO_ZORAN_DEBUG
 int videocodec_debugfs_show(struct seq_file *m)
@@ -286,25 +280,3 @@ int videocodec_debugfs_show(struct seq_file *m)
 	return 0;
 }
 #endif
-
-/* ===================== */
-/* hook in driver module */
-/* ===================== */
-static int __init videocodec_init(void)
-{
-	pr_info("Linux video codec intermediate layer: %s\n", VIDEOCODEC_VERSION);
-
-	return 0;
-}
-
-static void __exit videocodec_exit(void)
-{
-}
-
-module_init(videocodec_init);
-module_exit(videocodec_exit);
-
-MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
-MODULE_DESCRIPTION("Intermediate API module for video codecs "
-		   VIDEOCODEC_VERSION);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
index 1ed8ed2f4f7f..7b2e1d1c4622 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -29,6 +29,9 @@
 #include "zoran.h"
 #include "zoran_card.h"
 #include "zoran_device.h"
+#include "zr36016.h"
+#include "zr36050.h"
+#include "zr36060.h"
 
 extern const struct zoran_format zoran_formats[];
 
@@ -266,6 +269,39 @@ static const char *codecid_to_modulename(u16 codecid)
 	return name;
 }
 
+static int load_codec(struct zoran *zr, u16 codecid)
+{
+	switch (codecid) {
+	case CODEC_TYPE_ZR36060:
+#ifdef CONFIG_VIDEO_ZORAN_ZR36060
+		return zr36060_init_module();
+#else
+		pci_err(zr->pci_dev, "ZR36060 support is not enabled\n");
+		return -EINVAL;
+#endif
+		break;
+	case CODEC_TYPE_ZR36050:
+#ifdef CONFIG_VIDEO_ZORAN_DC30
+		return zr36050_init_module();
+#else
+		pci_err(zr->pci_dev, "ZR36050 support is not enabled\n");
+		return -EINVAL;
+#endif
+		break;
+	case CODEC_TYPE_ZR36016:
+#ifdef CONFIG_VIDEO_ZORAN_DC30
+		return zr36016_init_module();
+#else
+		pci_err(zr->pci_dev, "ZR36016 support is not enabled\n");
+		return -EINVAL;
+#endif
+		break;
+	}
+
+	pci_err(zr->pci_dev, "unknown codec id %x\n", codecid);
+	return -EINVAL;
+}
+
 // struct tvnorm {
 //      u16 wt, wa, h_start, h_sync_start, ht, ha, v_start;
 // };
@@ -1078,6 +1114,8 @@ static int zoran_debugfs_show(struct seq_file *seq, void *v)
 
 	seq_printf(seq, "Prepared %u\n", zr->prepared);
 	seq_printf(seq, "Queued %u\n", zr->queued);
+
+	videocodec_debugfs_show(seq);
 	return 0;
 }
 
@@ -1262,17 +1300,17 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (zr->card.video_codec) {
 		codec_name = codecid_to_modulename(zr->card.video_codec);
 		if (codec_name) {
-			result = request_module(codec_name);
-			if (result)
-				pci_err(pdev, "failed to load modules %s: %d\n", codec_name, result);
+			result = load_codec(zr, zr->card.video_codec);
+			if (result < 0)
+				pci_err(pdev, "failed to load codec %s: %d\n", codec_name, result);
 		}
 	}
 	if (zr->card.video_vfe) {
 		vfe_name = codecid_to_modulename(zr->card.video_vfe);
 		if (vfe_name) {
-			result = request_module(vfe_name);
+			result = load_codec(zr, zr->card.video_vfe);
 			if (result < 0)
-				pci_err(pdev, "failed to load modules %s: %d\n", vfe_name, result);
+				pci_err(pdev, "failed to load codec %s: %d\n", vfe_name, result);
 		}
 	}
 
diff --git a/drivers/staging/media/zoran/zr36016.c b/drivers/staging/media/zoran/zr36016.c
index 50605460a44b..adf738b5a1d5 100644
--- a/drivers/staging/media/zoran/zr36016.c
+++ b/drivers/staging/media/zoran/zr36016.c
@@ -409,14 +409,14 @@ static const struct videocodec zr36016_codec = {
    HOOK IN DRIVER AS KERNEL MODULE
    ========================================================================= */
 
-static int __init zr36016_init_module(void)
+int zr36016_init_module(void)
 {
 	//dprintk(1, "ZR36016 driver %s\n",ZR016_VERSION);
 	zr36016_codecs = 0;
 	return videocodec_register(&zr36016_codec);
 }
 
-static void __exit zr36016_cleanup_module(void)
+void zr36016_cleanup_module(void)
 {
 	if (zr36016_codecs) {
 		dprintk(1,
@@ -425,10 +425,3 @@ static void __exit zr36016_cleanup_module(void)
 	}
 	videocodec_unregister(&zr36016_codec);
 }
-
-module_init(zr36016_init_module);
-module_exit(zr36016_cleanup_module);
-
-MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
-MODULE_DESCRIPTION("Driver module for ZR36016 video frontends");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/zoran/zr36016.h b/drivers/staging/media/zoran/zr36016.h
index 1475f971cc24..04afba35669d 100644
--- a/drivers/staging/media/zoran/zr36016.h
+++ b/drivers/staging/media/zoran/zr36016.h
@@ -89,4 +89,6 @@ struct zr36016 {
 #define ZR016_SIGN           0x02
 #define ZR016_YMCS           0x01
 
+int zr36016_init_module(void);
+void zr36016_cleanup_module(void);
 #endif				/*fndef ZR36016_H */
diff --git a/drivers/staging/media/zoran/zr36050.c b/drivers/staging/media/zoran/zr36050.c
index 4dc7927fefc3..e36eff4a798c 100644
--- a/drivers/staging/media/zoran/zr36050.c
+++ b/drivers/staging/media/zoran/zr36050.c
@@ -817,14 +817,14 @@ static const struct videocodec zr36050_codec = {
    HOOK IN DRIVER AS KERNEL MODULE
    ========================================================================= */
 
-static int __init zr36050_init_module(void)
+int zr36050_init_module(void)
 {
 	//dprintk(1, "ZR36050 driver %s\n",ZR050_VERSION);
 	zr36050_codecs = 0;
 	return videocodec_register(&zr36050_codec);
 }
 
-static void __exit zr36050_cleanup_module(void)
+void zr36050_cleanup_module(void)
 {
 	if (zr36050_codecs) {
 		dprintk(1,
@@ -833,11 +833,3 @@ static void __exit zr36050_cleanup_module(void)
 	}
 	videocodec_unregister(&zr36050_codec);
 }
-
-module_init(zr36050_init_module);
-module_exit(zr36050_cleanup_module);
-
-MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
-MODULE_DESCRIPTION("Driver module for ZR36050 jpeg processors "
-		   ZR050_VERSION);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/zoran/zr36050.h b/drivers/staging/media/zoran/zr36050.h
index 8f972d045b58..f9b58f4c77b9 100644
--- a/drivers/staging/media/zoran/zr36050.h
+++ b/drivers/staging/media/zoran/zr36050.h
@@ -160,4 +160,6 @@ struct zr36050 {
 #define ZR050_U_COMPONENT         1
 #define ZR050_V_COMPONENT         2
 
+int zr36050_init_module(void);
+void zr36050_cleanup_module(void);
 #endif				/*fndef ZR36050_H */
diff --git a/drivers/staging/media/zoran/zr36060.c b/drivers/staging/media/zoran/zr36060.c
index 7904d5b1f402..0a6a8c985137 100644
--- a/drivers/staging/media/zoran/zr36060.c
+++ b/drivers/staging/media/zoran/zr36060.c
@@ -846,13 +846,13 @@ static const struct videocodec zr36060_codec = {
 	// others are not used
 };
 
-static int __init zr36060_init_module(void)
+int zr36060_init_module(void)
 {
 	zr36060_codecs = 0;
 	return videocodec_register(&zr36060_codec);
 }
 
-static void __exit zr36060_cleanup_module(void)
+void zr36060_cleanup_module(void)
 {
 	if (zr36060_codecs) {
 		dprintk(1,
@@ -863,10 +863,3 @@ static void __exit zr36060_cleanup_module(void)
 	/* however, we can't just stay alive */
 	videocodec_unregister(&zr36060_codec);
 }
-
-module_init(zr36060_init_module);
-module_exit(zr36060_cleanup_module);
-
-MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@skynet.be>");
-MODULE_DESCRIPTION("Driver module for ZR36060 jpeg processors " ZR060_VERSION);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/zoran/zr36060.h b/drivers/staging/media/zoran/zr36060.h
index d2cdc26bf625..fbf5429534ac 100644
--- a/drivers/staging/media/zoran/zr36060.h
+++ b/drivers/staging/media/zoran/zr36060.h
@@ -198,4 +198,6 @@ struct zr36060 {
 #define ZR060_SR_H_SCALE2		 BIT(0)
 #define ZR060_SR_H_SCALE4		(2 << 0)
 
+int zr36060_init_module(void);
+void zr36060_cleanup_module(void);
 #endif				/*fndef ZR36060_H */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 7/8] staging: media: zoran: remove vidmem
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (5 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 6/8] staging: media: zoran: fusion all modules Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-03 19:15 ` [PATCH 8/8] staging: media: zoran: move videodev alloc Corentin Labbe
  2021-09-06 11:03 ` [PATCH 0/8] staging: media: zoran: fusion in one module Hans Verkuil
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

The vidmem parameter is no longer necessary since we removed framebuffer
support.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/zoran_card.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
index 7b2e1d1c4622..ed74f04994da 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -39,17 +39,6 @@ static int card[BUZ_MAX] = { [0 ... (BUZ_MAX - 1)] = -1 };
 module_param_array(card, int, NULL, 0444);
 MODULE_PARM_DESC(card, "Card type");
 
-/*
- * The video mem address of the video card. The driver has a little database
- * for some videocards to determine it from there. If your video card is not
- * in there you have either to give it to the driver as a parameter or set
- * in a VIDIOCSFBUF ioctl
- */
-
-static unsigned long vidmem;	/* default = 0 - Video memory base address */
-module_param_hw(vidmem, ulong, iomem, 0444);
-MODULE_PARM_DESC(vidmem, "Default video memory base address");
-
 /* Default input and video norm at startup of the driver. */
 
 static unsigned int default_input;	/* default 0 = Composite, 1 = S-Video */
@@ -1161,10 +1150,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		jpg_bufsize = 8192;
 	if (jpg_bufsize > (512 * 1024))
 		jpg_bufsize = 512 * 1024;
-	/* Use parameter for vidmem or try to find a video card */
-	if (vidmem)
-		pci_info(pdev, "%s: Using supplied video memory base address @ 0x%lx\n",
-			 ZORAN_NAME, vidmem);
 
 	/* some mainboards might not do PCI-PCI data transfer well */
 	if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 8/8] staging: media: zoran: move videodev alloc
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (6 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 7/8] staging: media: zoran: remove vidmem Corentin Labbe
@ 2021-09-03 19:15 ` Corentin Labbe
  2021-09-06 11:03 ` [PATCH 0/8] staging: media: zoran: fusion in one module Hans Verkuil
  8 siblings, 0 replies; 23+ messages in thread
From: Corentin Labbe @ 2021-09-03 19:15 UTC (permalink / raw)
  To: gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users, Corentin Labbe

Move some code out of zr36057_init() and create new functions for handling zr->video_dev.
This permit to ease code reading and fix a zr->video_dev memory leak.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/zoran.h        |  2 +-
 drivers/staging/media/zoran/zoran_card.c   | 80 ++++++++++++++--------
 drivers/staging/media/zoran/zoran_driver.c |  5 +-
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
index 8c271005f14d..45f2d4d862b3 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -318,6 +318,6 @@ static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
 
 #endif
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 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 ed74f04994da..0b3afd8a702e 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -828,6 +828,52 @@ int zoran_check_jpg_settings(struct zoran *zr,
 	return 0;
 }
 
+static int zoran_init_video_device(struct zoran *zr, struct video_device *video_dev, int dir)
+{
+	int err;
+
+	/* Now add the template and register the device unit. */
+	*video_dev = zoran_template;
+	video_dev->v4l2_dev = &zr->v4l2_dev;
+	video_dev->lock = &zr->lock;
+	video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+
+	strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
+	/*
+	 * It's not a mem2mem device, but you can both capture and output from one and the same
+	 * device. This should really be split up into two device nodes, but that's a job for
+	 * another day.
+	 */
+	video_dev->vfl_dir = VFL_DIR_M2M;
+	zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+
+	err = video_register_device(video_dev, VFL_TYPE_VIDEO, video_nr[zr->id]);
+	if (err < 0)
+		return err;
+	video_set_drvdata(video_dev, zr);
+	return 0;
+}
+
+static void zoran_exit_video_devices(struct zoran *zr)
+{
+	video_unregister_device(zr->video_dev);
+	kfree(zr->video_dev);
+}
+
+static int zoran_init_video_devices(struct zoran *zr)
+{
+	int err;
+
+	zr->video_dev = video_device_alloc();
+	if (!zr->video_dev)
+		return -ENOMEM;
+
+	err = zoran_init_video_device(zr, zr->video_dev, V4L2_CAP_VIDEO_CAPTURE);
+	if (err)
+		kfree(zr->video_dev);
+	return err;
+}
+
 void zoran_open_init_params(struct zoran *zr)
 {
 	int i;
@@ -899,17 +945,11 @@ 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->video_dev = video_device_alloc();
-	if (!zr->video_dev) {
-		err = -ENOMEM;
-		goto exit;
-	}
 	zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
 					  BUZ_NUM_STAT_COM * sizeof(u32),
 					  &zr->p_sc, GFP_KERNEL);
 	if (!zr->stat_com) {
-		err = -ENOMEM;
-		goto exit_video;
+		return -ENOMEM;
 	}
 	for (j = 0; j < BUZ_NUM_STAT_COM; j++)
 		zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
@@ -922,26 +962,9 @@ static int zr36057_init(struct zoran *zr)
 		goto exit_statcom;
 	}
 
-	/* Now add the template and register the device unit. */
-	*zr->video_dev = zoran_template;
-	zr->video_dev->v4l2_dev = &zr->v4l2_dev;
-	zr->video_dev->lock = &zr->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
-	 * device. This should really be split up into two device nodes, but that's a job for
-	 * another day.
-	 */
-	zr->video_dev->vfl_dir = VFL_DIR_M2M;
-
-	zoran_queue_init(zr, &zr->vq);
-
-	err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, video_nr[zr->id]);
-	if (err < 0)
+	err = zoran_init_video_devices(zr);
+	if (err)
 		goto exit_statcomb;
-	video_set_drvdata(zr->video_dev, zr);
 
 	zoran_init_hardware(zr);
 	if (!pass_through) {
@@ -956,9 +979,6 @@ static int zr36057_init(struct zoran *zr)
 	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2, zr->stat_comb, zr->p_scb);
 exit_statcom:
 	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), zr->stat_com, zr->p_sc);
-exit_video:
-	kfree(zr->video_dev);
-exit:
 	return err;
 }
 
@@ -990,7 +1010,7 @@ static void zoran_remove(struct pci_dev *pdev)
 	dma_free_coherent(&zr->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);
+	zoran_exit_video_devices(zr);
 exit_free:
 	v4l2_ctrl_handler_free(&zr->hdl);
 	v4l2_device_unregister(&zr->v4l2_dev);
diff --git a/drivers/staging/media/zoran/zoran_driver.c b/drivers/staging/media/zoran/zoran_driver.c
index 46382e43f1bf..551db338c7f7 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1008,7 +1008,7 @@ static const struct vb2_ops zr_video_qops = {
 	.wait_finish            = vb2_ops_wait_finish,
 };
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq)
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir)
 {
 	int err;
 
@@ -1016,7 +1016,8 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq)
 	INIT_LIST_HEAD(&zr->queued_bufs);
 
 	vq->dev = &zr->pci_dev->dev;
-	vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	vq->type = dir;
+
 	vq->io_modes = VB2_USERPTR | VB2_DMABUF | VB2_MMAP | VB2_READ | VB2_WRITE;
 	vq->drv_priv = zr;
 	vq->buf_struct_size = sizeof(struct zr_buffer);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
@ 2021-09-03 23:28     ` kernel test robot
  2021-09-04  5:53   ` Greg KH
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2021-09-03 23:28 UTC (permalink / raw)
  To: Corentin Labbe, gregkh, mchehab
  Cc: kbuild-all, linux-kernel, linux-media, linux-staging,
	mjpeg-users, Corentin Labbe

[-- Attachment #1: Type: text/plain, Size: 3389 bytes --]

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 5d7d11dead3ea7191a8e8635fb718d0c3f203fe0
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
        git checkout 1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/staging/media/zoran/zoran_card.c: In function 'zoran_debugfs_show':
>> drivers/staging/media/zoran/zoran_card.c:1061:32: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'v4l2_std_id' {aka 'long long unsigned int'} [-Wformat=]
    1061 |         seq_printf(seq, "Norm %x\n", zr->norm);
         |                               ~^     ~~~~~~~~
         |                                |       |
         |                                |       v4l2_std_id {aka long long unsigned int}
         |                                unsigned int
         |                               %llx


vim +1061 drivers/staging/media/zoran/zoran_card.c

  1053	
  1054	#ifdef CONFIG_VIDEO_ZORAN_DEBUG
  1055	static int zoran_debugfs_show(struct seq_file *seq, void *v)
  1056	{
  1057		struct zoran *zr = seq->private;
  1058	
  1059		seq_printf(seq, "Running mode %x\n", zr->running);
  1060		seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> 1061		seq_printf(seq, "Norm %x\n", zr->norm);
  1062		seq_printf(seq, "Input %d\n", zr->input);
  1063		seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
  1064	
  1065		seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
  1066		seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
  1067	
  1068		seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
  1069		seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
  1070		seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
  1071		seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
  1072		seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
  1073		seq_printf(seq, "JPG crop %dx%d %d %d\n",
  1074			zr->jpg_settings.img_x,
  1075			zr->jpg_settings.img_y,
  1076			zr->jpg_settings.img_width,
  1077			zr->jpg_settings.img_height);
  1078	
  1079		seq_printf(seq, "Prepared %u\n", zr->prepared);
  1080		seq_printf(seq, "Queued %u\n", zr->queued);
  1081		return 0;
  1082	}
  1083	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 68888 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
@ 2021-09-03 23:28     ` kernel test robot
  0 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2021-09-03 23:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 5d7d11dead3ea7191a8e8635fb718d0c3f203fe0
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
        git checkout 1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/staging/media/zoran/zoran_card.c: In function 'zoran_debugfs_show':
>> drivers/staging/media/zoran/zoran_card.c:1061:32: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'v4l2_std_id' {aka 'long long unsigned int'} [-Wformat=]
    1061 |         seq_printf(seq, "Norm %x\n", zr->norm);
         |                               ~^     ~~~~~~~~
         |                                |       |
         |                                |       v4l2_std_id {aka long long unsigned int}
         |                                unsigned int
         |                               %llx


vim +1061 drivers/staging/media/zoran/zoran_card.c

  1053	
  1054	#ifdef CONFIG_VIDEO_ZORAN_DEBUG
  1055	static int zoran_debugfs_show(struct seq_file *seq, void *v)
  1056	{
  1057		struct zoran *zr = seq->private;
  1058	
  1059		seq_printf(seq, "Running mode %x\n", zr->running);
  1060		seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> 1061		seq_printf(seq, "Norm %x\n", zr->norm);
  1062		seq_printf(seq, "Input %d\n", zr->input);
  1063		seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
  1064	
  1065		seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
  1066		seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
  1067	
  1068		seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
  1069		seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
  1070		seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
  1071		seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
  1072		seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
  1073		seq_printf(seq, "JPG crop %dx%d %d %d\n",
  1074			zr->jpg_settings.img_x,
  1075			zr->jpg_settings.img_y,
  1076			zr->jpg_settings.img_width,
  1077			zr->jpg_settings.img_height);
  1078	
  1079		seq_printf(seq, "Prepared %u\n", zr->prepared);
  1080		seq_printf(seq, "Queued %u\n", zr->queued);
  1081		return 0;
  1082	}
  1083	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 68888 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
  2021-09-03 23:28     ` kernel test robot
@ 2021-09-04  5:53   ` Greg KH
  2021-09-06 13:36     ` LABBE Corentin
  2021-09-04  6:42     ` kernel test robot
  2021-09-06 10:20   ` Hans Verkuil
  3 siblings, 1 reply; 23+ messages in thread
From: Greg KH @ 2021-09-04  5:53 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

On Fri, Sep 03, 2021 at 07:15:36PM +0000, Corentin Labbe wrote:
> Add debugfs for displaying zoran debug and stats information.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/staging/media/zoran/Kconfig      | 10 ++++++
>  drivers/staging/media/zoran/zoran.h      |  5 +++
>  drivers/staging/media/zoran/zoran_card.c | 39 ++++++++++++++++++++++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig
> index 7874842033ca..7d2d3c2431b1 100644
> --- a/drivers/staging/media/zoran/Kconfig
> +++ b/drivers/staging/media/zoran/Kconfig
> @@ -74,3 +74,13 @@ config VIDEO_ZORAN_AVS6EYES
>  	select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT
>  	help
>  	  Support for the AverMedia 6 Eyes video surveillance card.
> +
> +config VIDEO_ZORAN_DEBUG
> +	bool "Enable zoran debugfs"
> +	depends on VIDEO_ZORAN
> +	depends on DEBUG_FS
> +	help
> +	  Say y to enable zoran debug file.
> +	  This will create /sys/kernel/debug/CARD_NAME/debug for displaying
> +	  stats and debug information.
> +
> diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
> index b1ad2a2b914c..8c271005f14d 100644
> --- a/drivers/staging/media/zoran/zoran.h
> +++ b/drivers/staging/media/zoran/zoran.h
> @@ -18,6 +18,7 @@
>  #ifndef _BUZ_H_
>  #define _BUZ_H_
>  
> +#include <linux/debugfs.h>
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-ctrls.h>
>  #include <media/videobuf2-core.h>
> @@ -295,6 +296,10 @@ struct zoran {
>  	struct list_head queued_bufs;
>  	spinlock_t queued_bufs_lock; /* Protects queued_bufs */
>  	struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2];
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +	struct dentry *dbgfs_dir;
> +	struct dentry *dbgfs_file;

No need for these, the file is never referenced and the directory can be
looked up when you want to remove it.

> +#endif
>  };
>  
>  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 f1465fbf98af..1ed8ed2f4f7f 100644
> --- a/drivers/staging/media/zoran/zoran_card.c
> +++ b/drivers/staging/media/zoran/zoran_card.c
> @@ -1051,6 +1051,39 @@ static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = {
>  	.s_ctrl = zoran_video_set_ctrl,
>  };
>  
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +static int zoran_debugfs_show(struct seq_file *seq, void *v)
> +{
> +	struct zoran *zr = seq->private;
> +
> +	seq_printf(seq, "Running mode %x\n", zr->running);
> +	seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> +	seq_printf(seq, "Norm %x\n", zr->norm);
> +	seq_printf(seq, "Input %d\n", zr->input);
> +	seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
> +
> +	seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
> +	seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
> +
> +	seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
> +	seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
> +	seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
> +	seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
> +	seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
> +	seq_printf(seq, "JPG crop %dx%d %d %d\n",
> +		zr->jpg_settings.img_x,
> +		zr->jpg_settings.img_y,
> +		zr->jpg_settings.img_width,
> +		zr->jpg_settings.img_height);
> +
> +	seq_printf(seq, "Prepared %u\n", zr->prepared);
> +	seq_printf(seq, "Queued %u\n", zr->queued);
> +	return 0;
> +}
> +
> +DEFINE_SHOW_ATTRIBUTE(zoran_debugfs);
> +#endif
> +
>  /*
>   *   Scan for a Buz card (actually for the PCI controller ZR36057),
>   *   request the irq and map the io memory
> @@ -1286,6 +1319,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	zr->map_mode = ZORAN_MAP_MODE_RAW;
>  
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +	zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL);
> +	zr->dbgfs_file = debugfs_create_file("debug", 0444,
> +					      zr->dbgfs_dir, zr,
> +					      &zoran_debugfs_fops);
> +#endif

Wait, when are you removing the files when the device is removed?

That needs to be fixed no matter what before this patch is accepted.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
@ 2021-09-04  6:42     ` kernel test robot
  2021-09-04  5:53   ` Greg KH
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2021-09-04  6:42 UTC (permalink / raw)
  To: Corentin Labbe, gregkh, mchehab
  Cc: llvm, kbuild-all, linux-kernel, linux-media, linux-staging,
	mjpeg-users, Corentin Labbe

[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 5d7d11dead3ea7191a8e8635fb718d0c3f203fe0
config: x86_64-randconfig-r023-20210904 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
        git checkout 1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/staging/media/zoran/zoran_card.c:1061:31: warning: format specifies type 'unsigned int' but the argument has type 'v4l2_std_id' (aka 'unsigned long long') [-Wformat]
           seq_printf(seq, "Norm %x\n", zr->norm);
                                 ~~     ^~~~~~~~
                                 %llx
   1 warning generated.


vim +1061 drivers/staging/media/zoran/zoran_card.c

  1053	
  1054	#ifdef CONFIG_VIDEO_ZORAN_DEBUG
  1055	static int zoran_debugfs_show(struct seq_file *seq, void *v)
  1056	{
  1057		struct zoran *zr = seq->private;
  1058	
  1059		seq_printf(seq, "Running mode %x\n", zr->running);
  1060		seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> 1061		seq_printf(seq, "Norm %x\n", zr->norm);
  1062		seq_printf(seq, "Input %d\n", zr->input);
  1063		seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
  1064	
  1065		seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
  1066		seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
  1067	
  1068		seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
  1069		seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
  1070		seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
  1071		seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
  1072		seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
  1073		seq_printf(seq, "JPG crop %dx%d %d %d\n",
  1074			zr->jpg_settings.img_x,
  1075			zr->jpg_settings.img_y,
  1076			zr->jpg_settings.img_width,
  1077			zr->jpg_settings.img_height);
  1078	
  1079		seq_printf(seq, "Prepared %u\n", zr->prepared);
  1080		seq_printf(seq, "Queued %u\n", zr->queued);
  1081		return 0;
  1082	}
  1083	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35303 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
@ 2021-09-04  6:42     ` kernel test robot
  0 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2021-09-04  6:42 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3251 bytes --]

Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 5d7d11dead3ea7191a8e8635fb718d0c3f203fe0
config: x86_64-randconfig-r023-20210904 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20210904-031844
        git checkout 1e16912d8cd1602ddb54f3e43e17021b8daf4e58
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/staging/media/zoran/zoran_card.c:1061:31: warning: format specifies type 'unsigned int' but the argument has type 'v4l2_std_id' (aka 'unsigned long long') [-Wformat]
           seq_printf(seq, "Norm %x\n", zr->norm);
                                 ~~     ^~~~~~~~
                                 %llx
   1 warning generated.


vim +1061 drivers/staging/media/zoran/zoran_card.c

  1053	
  1054	#ifdef CONFIG_VIDEO_ZORAN_DEBUG
  1055	static int zoran_debugfs_show(struct seq_file *seq, void *v)
  1056	{
  1057		struct zoran *zr = seq->private;
  1058	
  1059		seq_printf(seq, "Running mode %x\n", zr->running);
  1060		seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> 1061		seq_printf(seq, "Norm %x\n", zr->norm);
  1062		seq_printf(seq, "Input %d\n", zr->input);
  1063		seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
  1064	
  1065		seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
  1066		seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
  1067	
  1068		seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
  1069		seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
  1070		seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
  1071		seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
  1072		seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
  1073		seq_printf(seq, "JPG crop %dx%d %d %d\n",
  1074			zr->jpg_settings.img_x,
  1075			zr->jpg_settings.img_y,
  1076			zr->jpg_settings.img_width,
  1077			zr->jpg_settings.img_height);
  1078	
  1079		seq_printf(seq, "Prepared %u\n", zr->prepared);
  1080		seq_printf(seq, "Queued %u\n", zr->queued);
  1081		return 0;
  1082	}
  1083	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35303 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
                     ` (2 preceding siblings ...)
  2021-09-04  6:42     ` kernel test robot
@ 2021-09-06 10:20   ` Hans Verkuil
  3 siblings, 0 replies; 23+ messages in thread
From: Hans Verkuil @ 2021-09-06 10:20 UTC (permalink / raw)
  To: Corentin Labbe, gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users

On 03/09/2021 21:15, Corentin Labbe wrote:
> Add debugfs for displaying zoran debug and stats information.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/staging/media/zoran/Kconfig      | 10 ++++++
>  drivers/staging/media/zoran/zoran.h      |  5 +++
>  drivers/staging/media/zoran/zoran_card.c | 39 ++++++++++++++++++++++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig
> index 7874842033ca..7d2d3c2431b1 100644
> --- a/drivers/staging/media/zoran/Kconfig
> +++ b/drivers/staging/media/zoran/Kconfig
> @@ -74,3 +74,13 @@ config VIDEO_ZORAN_AVS6EYES
>  	select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT
>  	help
>  	  Support for the AverMedia 6 Eyes video surveillance card.
> +
> +config VIDEO_ZORAN_DEBUG
> +	bool "Enable zoran debugfs"
> +	depends on VIDEO_ZORAN
> +	depends on DEBUG_FS
> +	help
> +	  Say y to enable zoran debug file.
> +	  This will create /sys/kernel/debug/CARD_NAME/debug for displaying
> +	  stats and debug information.
> +
> diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
> index b1ad2a2b914c..8c271005f14d 100644
> --- a/drivers/staging/media/zoran/zoran.h
> +++ b/drivers/staging/media/zoran/zoran.h
> @@ -18,6 +18,7 @@
>  #ifndef _BUZ_H_
>  #define _BUZ_H_
>  
> +#include <linux/debugfs.h>
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-ctrls.h>
>  #include <media/videobuf2-core.h>
> @@ -295,6 +296,10 @@ struct zoran {
>  	struct list_head queued_bufs;
>  	spinlock_t queued_bufs_lock; /* Protects queued_bufs */
>  	struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2];
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +	struct dentry *dbgfs_dir;
> +	struct dentry *dbgfs_file;
> +#endif
>  };
>  
>  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 f1465fbf98af..1ed8ed2f4f7f 100644
> --- a/drivers/staging/media/zoran/zoran_card.c
> +++ b/drivers/staging/media/zoran/zoran_card.c
> @@ -1051,6 +1051,39 @@ static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = {
>  	.s_ctrl = zoran_video_set_ctrl,
>  };
>  
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +static int zoran_debugfs_show(struct seq_file *seq, void *v)
> +{
> +	struct zoran *zr = seq->private;
> +
> +	seq_printf(seq, "Running mode %x\n", zr->running);
> +	seq_printf(seq, "Codec mode %x\n", zr->codec_mode);
> +	seq_printf(seq, "Norm %x\n", zr->norm);

This should be %llx, otherwise you get a compile warning.

Regards,

	Hans

> +	seq_printf(seq, "Input %d\n", zr->input);
> +	seq_printf(seq, "Buffersize %d\n", zr->buffer_size);
> +
> +	seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height);
> +	seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline);
> +
> +	seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation);
> +	seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm);
> +	seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm);
> +	seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm);
> +	seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even);
> +	seq_printf(seq, "JPG crop %dx%d %d %d\n",
> +		zr->jpg_settings.img_x,
> +		zr->jpg_settings.img_y,
> +		zr->jpg_settings.img_width,
> +		zr->jpg_settings.img_height);
> +
> +	seq_printf(seq, "Prepared %u\n", zr->prepared);
> +	seq_printf(seq, "Queued %u\n", zr->queued);
> +	return 0;
> +}
> +
> +DEFINE_SHOW_ATTRIBUTE(zoran_debugfs);
> +#endif
> +
>  /*
>   *   Scan for a Buz card (actually for the PCI controller ZR36057),
>   *   request the irq and map the io memory
> @@ -1286,6 +1319,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	zr->map_mode = ZORAN_MAP_MODE_RAW;
>  
> +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> +	zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL);
> +	zr->dbgfs_file = debugfs_create_file("debug", 0444,
> +					      zr->dbgfs_dir, zr,
> +					      &zoran_debugfs_fops);
> +#endif
>  	return 0;
>  
>  zr_detach_vfe:
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 6/8] staging: media: zoran: fusion all modules
  2021-09-03 19:15 ` [PATCH 6/8] staging: media: zoran: fusion all modules Corentin Labbe
@ 2021-09-06 10:41   ` Hans Verkuil
  2021-09-06 13:40     ` LABBE Corentin
  0 siblings, 1 reply; 23+ messages in thread
From: Hans Verkuil @ 2021-09-06 10:41 UTC (permalink / raw)
  To: Corentin Labbe, gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users

On 03/09/2021 21:15, Corentin Labbe wrote:
> The zoran driver is split in many modules, but this lead to some
> problems.
> One of them is that load order is incorrect when everything is built-in.
> 
> Having more than one module is useless, so fusion all zoran modules in
> one.

After applying this patch I am no longer able to rmmod the module: it will
always report that it is in use. This is with a Miro DC30.

So something is wrong with refcounting.

I do like the idea of merging all these modules, but it needs a bit more
testing.

Regards,

	Hans

> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/staging/media/zoran/Kconfig      | 14 +++----
>  drivers/staging/media/zoran/Makefile     |  8 ++--
>  drivers/staging/media/zoran/videocodec.c | 28 --------------
>  drivers/staging/media/zoran/zoran_card.c | 48 +++++++++++++++++++++---
>  drivers/staging/media/zoran/zr36016.c    | 11 +-----
>  drivers/staging/media/zoran/zr36016.h    |  2 +
>  drivers/staging/media/zoran/zr36050.c    | 12 +-----
>  drivers/staging/media/zoran/zr36050.h    |  2 +
>  drivers/staging/media/zoran/zr36060.c    | 11 +-----
>  drivers/staging/media/zoran/zr36060.h    |  2 +
>  10 files changed, 66 insertions(+), 72 deletions(-)
> 
> diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig
> index 7d2d3c2431b1..8eacdc00b081 100644
> --- a/drivers/staging/media/zoran/Kconfig
> +++ b/drivers/staging/media/zoran/Kconfig
> @@ -14,7 +14,7 @@ config VIDEO_ZORAN
>  	  module will be called zr36067.
>  
>  config VIDEO_ZORAN_DC30
> -	tristate "Pinnacle/Miro DC30(+) support"
> +	bool "Pinnacle/Miro DC30(+) support"
>  	depends on VIDEO_ZORAN
>  	select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_VPX3220 if MEDIA_SUBDRV_AUTOSELECT
> @@ -24,7 +24,7 @@ config VIDEO_ZORAN_DC30
>  	  zr36050 MJPEG codec and zr36016 VFE.
>  
>  config VIDEO_ZORAN_ZR36060
> -	tristate "Zoran ZR36060"
> +	bool "Zoran ZR36060"
>  	depends on VIDEO_ZORAN
>  	help
>  	  Say Y to support Zoran boards based on 36060 chips.
> @@ -32,7 +32,7 @@ config VIDEO_ZORAN_ZR36060
>  	  and 33 R10 and AverMedia 6 boards.
>  
>  config VIDEO_ZORAN_BUZ
> -	tristate "Iomega Buz support"
> +	bool "Iomega Buz support"
>  	depends on VIDEO_ZORAN_ZR36060
>  	select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_SAA7185 if MEDIA_SUBDRV_AUTOSELECT
> @@ -40,7 +40,7 @@ config VIDEO_ZORAN_BUZ
>  	  Support for the Iomega Buz MJPEG capture/playback card.
>  
>  config VIDEO_ZORAN_DC10
> -	tristate "Pinnacle/Miro DC10(+) support"
> +	bool "Pinnacle/Miro DC10(+) support"
>  	depends on VIDEO_ZORAN_ZR36060
>  	select VIDEO_SAA7110 if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT
> @@ -49,7 +49,7 @@ config VIDEO_ZORAN_DC10
>  	  card.
>  
>  config VIDEO_ZORAN_LML33
> -	tristate "Linux Media Labs LML33 support"
> +	bool "Linux Media Labs LML33 support"
>  	depends on VIDEO_ZORAN_ZR36060
>  	select VIDEO_BT819 if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT
> @@ -58,7 +58,7 @@ config VIDEO_ZORAN_LML33
>  	  card.
>  
>  config VIDEO_ZORAN_LML33R10
> -	tristate "Linux Media Labs LML33R10 support"
> +	bool "Linux Media Labs LML33R10 support"
>  	depends on VIDEO_ZORAN_ZR36060
>  	select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_ADV7170 if MEDIA_SUBDRV_AUTOSELECT
> @@ -67,7 +67,7 @@ config VIDEO_ZORAN_LML33R10
>  	  card.
>  
>  config VIDEO_ZORAN_AVS6EYES
> -	tristate "AverMedia 6 Eyes support"
> +	bool "AverMedia 6 Eyes support"
>  	depends on VIDEO_ZORAN_ZR36060
>  	select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT
>  	select VIDEO_BT866 if MEDIA_SUBDRV_AUTOSELECT
> diff --git a/drivers/staging/media/zoran/Makefile b/drivers/staging/media/zoran/Makefile
> index 7023158e3892..9603bac0195c 100644
> --- a/drivers/staging/media/zoran/Makefile
> +++ b/drivers/staging/media/zoran/Makefile
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  zr36067-objs	:=	zoran_device.o \
> -			zoran_driver.o zoran_card.o
> +			zoran_driver.o zoran_card.o videocodec.o
>  
> -obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o
> -obj-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
> -obj-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
> +obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o
> +zr36067-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
> +zr36067-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
> diff --git a/drivers/staging/media/zoran/videocodec.c b/drivers/staging/media/zoran/videocodec.c
> index 3d5a83a07e07..7350d7747516 100644
> --- a/drivers/staging/media/zoran/videocodec.c
> +++ b/drivers/staging/media/zoran/videocodec.c
> @@ -8,8 +8,6 @@
>   * (c) 2002 Wolfgang Scherr <scherr@net4you.at>
>   */
>  
> -#define VIDEOCODEC_VERSION "v0.2"
> -
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/init.h>
> @@ -119,7 +117,6 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)
>  	kfree(codec);
>  	return NULL;
>  }
> -EXPORT_SYMBOL(videocodec_attach);
>  
>  int videocodec_detach(struct videocodec *codec)
>  {
> @@ -175,7 +172,6 @@ int videocodec_detach(struct videocodec *codec)
>  	pr_err("%s: given codec not found!\n", __func__);
>  	return -EINVAL;
>  }
> -EXPORT_SYMBOL(videocodec_detach);
>  
>  int videocodec_register(const struct videocodec *codec)
>  {
> @@ -208,7 +204,6 @@ int videocodec_register(const struct videocodec *codec)
>  
>  	return 0;
>  }
> -EXPORT_SYMBOL(videocodec_register);
>  
>  int videocodec_unregister(const struct videocodec *codec)
>  {
> @@ -255,7 +250,6 @@ int videocodec_unregister(const struct videocodec *codec)
>  	pr_err("%s: given codec not found!\n", __func__);
>  	return -EINVAL;
>  }
> -EXPORT_SYMBOL(videocodec_unregister);
>  
>  #ifdef CONFIG_VIDEO_ZORAN_DEBUG
>  int videocodec_debugfs_show(struct seq_file *m)
> @@ -286,25 +280,3 @@ int videocodec_debugfs_show(struct seq_file *m)
>  	return 0;
>  }
>  #endif
> -
> -/* ===================== */
> -/* hook in driver module */
> -/* ===================== */
> -static int __init videocodec_init(void)
> -{
> -	pr_info("Linux video codec intermediate layer: %s\n", VIDEOCODEC_VERSION);
> -
> -	return 0;
> -}
> -
> -static void __exit videocodec_exit(void)
> -{
> -}
> -
> -module_init(videocodec_init);
> -module_exit(videocodec_exit);
> -
> -MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
> -MODULE_DESCRIPTION("Intermediate API module for video codecs "
> -		   VIDEOCODEC_VERSION);
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
> index 1ed8ed2f4f7f..7b2e1d1c4622 100644
> --- a/drivers/staging/media/zoran/zoran_card.c
> +++ b/drivers/staging/media/zoran/zoran_card.c
> @@ -29,6 +29,9 @@
>  #include "zoran.h"
>  #include "zoran_card.h"
>  #include "zoran_device.h"
> +#include "zr36016.h"
> +#include "zr36050.h"
> +#include "zr36060.h"
>  
>  extern const struct zoran_format zoran_formats[];
>  
> @@ -266,6 +269,39 @@ static const char *codecid_to_modulename(u16 codecid)
>  	return name;
>  }
>  
> +static int load_codec(struct zoran *zr, u16 codecid)
> +{
> +	switch (codecid) {
> +	case CODEC_TYPE_ZR36060:
> +#ifdef CONFIG_VIDEO_ZORAN_ZR36060
> +		return zr36060_init_module();
> +#else
> +		pci_err(zr->pci_dev, "ZR36060 support is not enabled\n");
> +		return -EINVAL;
> +#endif
> +		break;
> +	case CODEC_TYPE_ZR36050:
> +#ifdef CONFIG_VIDEO_ZORAN_DC30
> +		return zr36050_init_module();
> +#else
> +		pci_err(zr->pci_dev, "ZR36050 support is not enabled\n");
> +		return -EINVAL;
> +#endif
> +		break;
> +	case CODEC_TYPE_ZR36016:
> +#ifdef CONFIG_VIDEO_ZORAN_DC30
> +		return zr36016_init_module();
> +#else
> +		pci_err(zr->pci_dev, "ZR36016 support is not enabled\n");
> +		return -EINVAL;
> +#endif
> +		break;
> +	}
> +
> +	pci_err(zr->pci_dev, "unknown codec id %x\n", codecid);
> +	return -EINVAL;
> +}
> +
>  // struct tvnorm {
>  //      u16 wt, wa, h_start, h_sync_start, ht, ha, v_start;
>  // };
> @@ -1078,6 +1114,8 @@ static int zoran_debugfs_show(struct seq_file *seq, void *v)
>  
>  	seq_printf(seq, "Prepared %u\n", zr->prepared);
>  	seq_printf(seq, "Queued %u\n", zr->queued);
> +
> +	videocodec_debugfs_show(seq);
>  	return 0;
>  }
>  
> @@ -1262,17 +1300,17 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	if (zr->card.video_codec) {
>  		codec_name = codecid_to_modulename(zr->card.video_codec);
>  		if (codec_name) {
> -			result = request_module(codec_name);
> -			if (result)
> -				pci_err(pdev, "failed to load modules %s: %d\n", codec_name, result);
> +			result = load_codec(zr, zr->card.video_codec);
> +			if (result < 0)
> +				pci_err(pdev, "failed to load codec %s: %d\n", codec_name, result);
>  		}
>  	}
>  	if (zr->card.video_vfe) {
>  		vfe_name = codecid_to_modulename(zr->card.video_vfe);
>  		if (vfe_name) {
> -			result = request_module(vfe_name);
> +			result = load_codec(zr, zr->card.video_vfe);
>  			if (result < 0)
> -				pci_err(pdev, "failed to load modules %s: %d\n", vfe_name, result);
> +				pci_err(pdev, "failed to load codec %s: %d\n", vfe_name, result);
>  		}
>  	}
>  
> diff --git a/drivers/staging/media/zoran/zr36016.c b/drivers/staging/media/zoran/zr36016.c
> index 50605460a44b..adf738b5a1d5 100644
> --- a/drivers/staging/media/zoran/zr36016.c
> +++ b/drivers/staging/media/zoran/zr36016.c
> @@ -409,14 +409,14 @@ static const struct videocodec zr36016_codec = {
>     HOOK IN DRIVER AS KERNEL MODULE
>     ========================================================================= */
>  
> -static int __init zr36016_init_module(void)
> +int zr36016_init_module(void)
>  {
>  	//dprintk(1, "ZR36016 driver %s\n",ZR016_VERSION);
>  	zr36016_codecs = 0;
>  	return videocodec_register(&zr36016_codec);
>  }
>  
> -static void __exit zr36016_cleanup_module(void)
> +void zr36016_cleanup_module(void)
>  {
>  	if (zr36016_codecs) {
>  		dprintk(1,
> @@ -425,10 +425,3 @@ static void __exit zr36016_cleanup_module(void)
>  	}
>  	videocodec_unregister(&zr36016_codec);
>  }
> -
> -module_init(zr36016_init_module);
> -module_exit(zr36016_cleanup_module);
> -
> -MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
> -MODULE_DESCRIPTION("Driver module for ZR36016 video frontends");
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/staging/media/zoran/zr36016.h b/drivers/staging/media/zoran/zr36016.h
> index 1475f971cc24..04afba35669d 100644
> --- a/drivers/staging/media/zoran/zr36016.h
> +++ b/drivers/staging/media/zoran/zr36016.h
> @@ -89,4 +89,6 @@ struct zr36016 {
>  #define ZR016_SIGN           0x02
>  #define ZR016_YMCS           0x01
>  
> +int zr36016_init_module(void);
> +void zr36016_cleanup_module(void);
>  #endif				/*fndef ZR36016_H */
> diff --git a/drivers/staging/media/zoran/zr36050.c b/drivers/staging/media/zoran/zr36050.c
> index 4dc7927fefc3..e36eff4a798c 100644
> --- a/drivers/staging/media/zoran/zr36050.c
> +++ b/drivers/staging/media/zoran/zr36050.c
> @@ -817,14 +817,14 @@ static const struct videocodec zr36050_codec = {
>     HOOK IN DRIVER AS KERNEL MODULE
>     ========================================================================= */
>  
> -static int __init zr36050_init_module(void)
> +int zr36050_init_module(void)
>  {
>  	//dprintk(1, "ZR36050 driver %s\n",ZR050_VERSION);
>  	zr36050_codecs = 0;
>  	return videocodec_register(&zr36050_codec);
>  }
>  
> -static void __exit zr36050_cleanup_module(void)
> +void zr36050_cleanup_module(void)
>  {
>  	if (zr36050_codecs) {
>  		dprintk(1,
> @@ -833,11 +833,3 @@ static void __exit zr36050_cleanup_module(void)
>  	}
>  	videocodec_unregister(&zr36050_codec);
>  }
> -
> -module_init(zr36050_init_module);
> -module_exit(zr36050_cleanup_module);
> -
> -MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
> -MODULE_DESCRIPTION("Driver module for ZR36050 jpeg processors "
> -		   ZR050_VERSION);
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/staging/media/zoran/zr36050.h b/drivers/staging/media/zoran/zr36050.h
> index 8f972d045b58..f9b58f4c77b9 100644
> --- a/drivers/staging/media/zoran/zr36050.h
> +++ b/drivers/staging/media/zoran/zr36050.h
> @@ -160,4 +160,6 @@ struct zr36050 {
>  #define ZR050_U_COMPONENT         1
>  #define ZR050_V_COMPONENT         2
>  
> +int zr36050_init_module(void);
> +void zr36050_cleanup_module(void);
>  #endif				/*fndef ZR36050_H */
> diff --git a/drivers/staging/media/zoran/zr36060.c b/drivers/staging/media/zoran/zr36060.c
> index 7904d5b1f402..0a6a8c985137 100644
> --- a/drivers/staging/media/zoran/zr36060.c
> +++ b/drivers/staging/media/zoran/zr36060.c
> @@ -846,13 +846,13 @@ static const struct videocodec zr36060_codec = {
>  	// others are not used
>  };
>  
> -static int __init zr36060_init_module(void)
> +int zr36060_init_module(void)
>  {
>  	zr36060_codecs = 0;
>  	return videocodec_register(&zr36060_codec);
>  }
>  
> -static void __exit zr36060_cleanup_module(void)
> +void zr36060_cleanup_module(void)
>  {
>  	if (zr36060_codecs) {
>  		dprintk(1,
> @@ -863,10 +863,3 @@ static void __exit zr36060_cleanup_module(void)
>  	/* however, we can't just stay alive */
>  	videocodec_unregister(&zr36060_codec);
>  }
> -
> -module_init(zr36060_init_module);
> -module_exit(zr36060_cleanup_module);
> -
> -MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@skynet.be>");
> -MODULE_DESCRIPTION("Driver module for ZR36060 jpeg processors " ZR060_VERSION);
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/staging/media/zoran/zr36060.h b/drivers/staging/media/zoran/zr36060.h
> index d2cdc26bf625..fbf5429534ac 100644
> --- a/drivers/staging/media/zoran/zr36060.h
> +++ b/drivers/staging/media/zoran/zr36060.h
> @@ -198,4 +198,6 @@ struct zr36060 {
>  #define ZR060_SR_H_SCALE2		 BIT(0)
>  #define ZR060_SR_H_SCALE4		(2 << 0)
>  
> +int zr36060_init_module(void);
> +void zr36060_cleanup_module(void);
>  #endif				/*fndef ZR36060_H */
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/8] staging: media: zoran: fusion in one module
  2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
                   ` (7 preceding siblings ...)
  2021-09-03 19:15 ` [PATCH 8/8] staging: media: zoran: move videodev alloc Corentin Labbe
@ 2021-09-06 11:03 ` Hans Verkuil
  2021-09-06 13:49   ` LABBE Corentin
  8 siblings, 1 reply; 23+ messages in thread
From: Hans Verkuil @ 2021-09-06 11:03 UTC (permalink / raw)
  To: Corentin Labbe, gregkh, mchehab
  Cc: linux-kernel, linux-media, linux-staging, mjpeg-users

Hi Corentin,

I finally had the opportunity to test the staging zoran driver.

I found several issues when running v4l2-compliance -s (I posted a patch
for that), but more seriously is the fact that trying to capture MJPG
at resolutions 384x288 or less just hangs my PC. It works OK with 768x576.

I discovered this when running 'v4l2-compliance -s -a -f'.

BTW, why isn't the initial format equal to MJPG 768x576?
I would expect that for these boards that should be the default format.

Another issue is that the TODO should mention that for video output there
should be a second video device node. And that's really something that
has to be done before the zoran driver can be moved out of staging.

It shouldn't be that hard to implement, I think.

Right now it is impossible to run the compliance test for the output, since
it doesn't even see it as an output.

Regards,

	Hans

On 03/09/2021 21:15, Corentin Labbe wrote:
> Hello
> 
> The main change of this serie is to fusion all zoran related modules in
> one.
> This fixes the load order problem when everything is built-in.
> 
> Regards
> 
> Corentin Labbe (8):
>   staging: media: zoran: move module parameter checks to zoran_probe
>   staging: media: zoran: use module_pci_driver
>   staging: media: zoran: rename debug module parameter
>   staging: media: zoran: add debugfs
>   staging: media: zoran: videocode: remove procfs
>   staging: media: zoran: fusion all modules
>   staging: media: zoran: remove vidmem
>   staging: media: zoran: move videodev alloc
> 
>  drivers/staging/media/zoran/Kconfig        |  24 +-
>  drivers/staging/media/zoran/Makefile       |   8 +-
>  drivers/staging/media/zoran/videocodec.c   |  60 +----
>  drivers/staging/media/zoran/videocodec.h   |   5 +
>  drivers/staging/media/zoran/zoran.h        |   7 +-
>  drivers/staging/media/zoran/zoran_card.c   | 259 +++++++++++++--------
>  drivers/staging/media/zoran/zoran_driver.c |   5 +-
>  drivers/staging/media/zoran/zr36016.c      |  23 +-
>  drivers/staging/media/zoran/zr36016.h      |   2 +
>  drivers/staging/media/zoran/zr36050.c      |  20 +-
>  drivers/staging/media/zoran/zr36050.h      |   2 +
>  drivers/staging/media/zoran/zr36060.c      |  20 +-
>  drivers/staging/media/zoran/zr36060.h      |   2 +
>  13 files changed, 229 insertions(+), 208 deletions(-)
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] staging: media: zoran: add debugfs
  2021-09-04  5:53   ` Greg KH
@ 2021-09-06 13:36     ` LABBE Corentin
  0 siblings, 0 replies; 23+ messages in thread
From: LABBE Corentin @ 2021-09-06 13:36 UTC (permalink / raw)
  To: Greg KH; +Cc: mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

Le Sat, Sep 04, 2021 at 07:53:00AM +0200, Greg KH a écrit :
> On Fri, Sep 03, 2021 at 07:15:36PM +0000, Corentin Labbe wrote:
> > Add debugfs for displaying zoran debug and stats information.
> > 
> > Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> > ---
> >  drivers/staging/media/zoran/Kconfig      | 10 ++++++
> >  drivers/staging/media/zoran/zoran.h      |  5 +++
> >  drivers/staging/media/zoran/zoran_card.c | 39 ++++++++++++++++++++++++
> >  3 files changed, 54 insertions(+)
> > 
> > +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> > +	struct dentry *dbgfs_dir;
> > +	struct dentry *dbgfs_file;
> 
> No need for these, the file is never referenced and the directory can be
> looked up when you want to remove it.
> 
> > +#endif
[...]
> > +#ifdef CONFIG_VIDEO_ZORAN_DEBUG
> > +	zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL);
> > +	zr->dbgfs_file = debugfs_create_file("debug", 0444,
> > +					      zr->dbgfs_dir, zr,
> > +					      &zoran_debugfs_fops);
> > +#endif
> 
> Wait, when are you removing the files when the device is removed?
> 
> That needs to be fixed no matter what before this patch is accepted.
> 

Hello

Sorry to have forgotten this.
I will fix this.

Thanks
Regards

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 6/8] staging: media: zoran: fusion all modules
  2021-09-06 10:41   ` Hans Verkuil
@ 2021-09-06 13:40     ` LABBE Corentin
  0 siblings, 0 replies; 23+ messages in thread
From: LABBE Corentin @ 2021-09-06 13:40 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: gregkh, mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

Le Mon, Sep 06, 2021 at 12:41:32PM +0200, Hans Verkuil a écrit :
> On 03/09/2021 21:15, Corentin Labbe wrote:
> > The zoran driver is split in many modules, but this lead to some
> > problems.
> > One of them is that load order is incorrect when everything is built-in.
> > 
> > Having more than one module is useless, so fusion all zoran modules in
> > one.
> 
> After applying this patch I am no longer able to rmmod the module: it will
> always report that it is in use. This is with a Miro DC30.
> 
> So something is wrong with refcounting.
> 
> I do like the idea of merging all these modules, but it needs a bit more
> testing.
> 
> Regards,
> 
> 	Hans
> 

Hello

I am sorry, I was sure to have successfully removed the zoran module a couple of time with my DC10.
Anyway I just acquired a DC30, so I will test it also (even if I believe that model should not change anything).

Regards

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/8] staging: media: zoran: fusion in one module
  2021-09-06 11:03 ` [PATCH 0/8] staging: media: zoran: fusion in one module Hans Verkuil
@ 2021-09-06 13:49   ` LABBE Corentin
  2021-09-06 14:11     ` Hans Verkuil
  0 siblings, 1 reply; 23+ messages in thread
From: LABBE Corentin @ 2021-09-06 13:49 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: gregkh, mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

Le Mon, Sep 06, 2021 at 01:03:56PM +0200, Hans Verkuil a écrit :
> Hi Corentin,
> 
> I finally had the opportunity to test the staging zoran driver.
> 
> I found several issues when running v4l2-compliance -s (I posted a patch
> for that), but more seriously is the fact that trying to capture MJPG
> at resolutions 384x288 or less just hangs my PC. It works OK with 768x576.
> 
> I discovered this when running 'v4l2-compliance -s -a -f'.
> 
> BTW, why isn't the initial format equal to MJPG 768x576?
> I would expect that for these boards that should be the default format.
> 
> Another issue is that the TODO should mention that for video output there
> should be a second video device node. And that's really something that
> has to be done before the zoran driver can be moved out of staging.
> 
> It shouldn't be that hard to implement, I think.
> 
> Right now it is impossible to run the compliance test for the output, since
> it doesn't even see it as an output.
> 
> Regards,
> 
> 	Hans

I work on having a second device for output, (it is the reason of "staging: media: zoran: move videodev alloc" which will help).

But I still have the problem of non working output.

Does output is really needed for going out of staging ?
Probably nobody have it working for ages. The only way to had it was to use an old mplayer output which is broken since so many time.
Note that this plugin will never work again.

The only way to work on output is to use ffmpeg which just recently have suport for writing non-raw video to V4L.

Regards

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/8] staging: media: zoran: fusion in one module
  2021-09-06 13:49   ` LABBE Corentin
@ 2021-09-06 14:11     ` Hans Verkuil
  2021-09-06 14:56       ` LABBE Corentin
  0 siblings, 1 reply; 23+ messages in thread
From: Hans Verkuil @ 2021-09-06 14:11 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: gregkh, mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

On 06/09/2021 15:49, LABBE Corentin wrote:
> Le Mon, Sep 06, 2021 at 01:03:56PM +0200, Hans Verkuil a écrit :
>> Hi Corentin,
>>
>> I finally had the opportunity to test the staging zoran driver.
>>
>> I found several issues when running v4l2-compliance -s (I posted a patch
>> for that), but more seriously is the fact that trying to capture MJPG
>> at resolutions 384x288 or less just hangs my PC. It works OK with 768x576.
>>
>> I discovered this when running 'v4l2-compliance -s -a -f'.
>>
>> BTW, why isn't the initial format equal to MJPG 768x576?
>> I would expect that for these boards that should be the default format.
>>
>> Another issue is that the TODO should mention that for video output there
>> should be a second video device node. And that's really something that
>> has to be done before the zoran driver can be moved out of staging.
>>
>> It shouldn't be that hard to implement, I think.
>>
>> Right now it is impossible to run the compliance test for the output, since
>> it doesn't even see it as an output.
>>
>> Regards,
>>
>> 	Hans
> 
> I work on having a second device for output, (it is the reason of "staging: media: zoran: move videodev alloc" which will help).
> 
> But I still have the problem of non working output.
> 
> Does output is really needed for going out of staging ?
> Probably nobody have it working for ages. The only way to had it was to use an old mplayer output which is broken since so many time.
> Note that this plugin will never work again.
> 
> The only way to work on output is to use ffmpeg which just recently have suport for writing non-raw video to V4L.

Then just remove it. The code for output remains in the git history so if someone wants to
resurrect that, then that's always possible.

The point is that I don't want to have half-baked output support in mainline.

But what exactly is the problem with getting output to work? Doesn't it just decode
MJPEG frames? (Sorry if you explained it before, it's so long ago that I looked at this
that I forgot the details)

In any case, before the driver can be moved out of staging video output should either
be working or removed. Either is fine, but not the halfway state it is in today.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/8] staging: media: zoran: fusion in one module
  2021-09-06 14:11     ` Hans Verkuil
@ 2021-09-06 14:56       ` LABBE Corentin
  2021-09-06 15:06         ` Hans Verkuil
  0 siblings, 1 reply; 23+ messages in thread
From: LABBE Corentin @ 2021-09-06 14:56 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: gregkh, mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

Le Mon, Sep 06, 2021 at 04:11:16PM +0200, Hans Verkuil a écrit :
> On 06/09/2021 15:49, LABBE Corentin wrote:
> > Le Mon, Sep 06, 2021 at 01:03:56PM +0200, Hans Verkuil a écrit :
> >> Hi Corentin,
> >>
> >> I finally had the opportunity to test the staging zoran driver.
> >>
> >> I found several issues when running v4l2-compliance -s (I posted a patch
> >> for that), but more seriously is the fact that trying to capture MJPG
> >> at resolutions 384x288 or less just hangs my PC. It works OK with 768x576.
> >>
> >> I discovered this when running 'v4l2-compliance -s -a -f'.
> >>
> >> BTW, why isn't the initial format equal to MJPG 768x576?
> >> I would expect that for these boards that should be the default format.
> >>
> >> Another issue is that the TODO should mention that for video output there
> >> should be a second video device node. And that's really something that
> >> has to be done before the zoran driver can be moved out of staging.
> >>
> >> It shouldn't be that hard to implement, I think.
> >>
> >> Right now it is impossible to run the compliance test for the output, since
> >> it doesn't even see it as an output.
> >>
> >> Regards,
> >>
> >> 	Hans
> > 
> > I work on having a second device for output, (it is the reason of "staging: media: zoran: move videodev alloc" which will help).
> > 
> > But I still have the problem of non working output.
> > 
> > Does output is really needed for going out of staging ?
> > Probably nobody have it working for ages. The only way to had it was to use an old mplayer output which is broken since so many time.
> > Note that this plugin will never work again.
> > 
> > The only way to work on output is to use ffmpeg which just recently have suport for writing non-raw video to V4L.
> 
> Then just remove it. The code for output remains in the git history so if someone wants to
> resurrect that, then that's always possible.
> 
> The point is that I don't want to have half-baked output support in mainline.
> 
> But what exactly is the problem with getting output to work? Doesn't it just decode
> MJPEG frames? (Sorry if you explained it before, it's so long ago that I looked at this
> that I forgot the details)
> 

The first problem is that zoran dont like comment COM/APP0 markers.
This imply a per buffer filtering but this is already handled in my next branch.

But the remaining problem is that any output is like http://kernel.montjoie.ovh/zoran_out.png.

I hacked the driver to grab a working buffer when doing input and overrun output buffer later.
And the result is a working static output.
So the hw handling is good and the problem came from the data feeding/handling.

I believe that something is wrong in what ffmpeg negociate/send.

Regards

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/8] staging: media: zoran: fusion in one module
  2021-09-06 14:56       ` LABBE Corentin
@ 2021-09-06 15:06         ` Hans Verkuil
  0 siblings, 0 replies; 23+ messages in thread
From: Hans Verkuil @ 2021-09-06 15:06 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: gregkh, mchehab, linux-kernel, linux-media, linux-staging, mjpeg-users

On 06/09/2021 16:56, LABBE Corentin wrote:
> Le Mon, Sep 06, 2021 at 04:11:16PM +0200, Hans Verkuil a écrit :
>> On 06/09/2021 15:49, LABBE Corentin wrote:
>>> Le Mon, Sep 06, 2021 at 01:03:56PM +0200, Hans Verkuil a écrit :
>>>> Hi Corentin,
>>>>
>>>> I finally had the opportunity to test the staging zoran driver.
>>>>
>>>> I found several issues when running v4l2-compliance -s (I posted a patch
>>>> for that), but more seriously is the fact that trying to capture MJPG
>>>> at resolutions 384x288 or less just hangs my PC. It works OK with 768x576.
>>>>
>>>> I discovered this when running 'v4l2-compliance -s -a -f'.
>>>>
>>>> BTW, why isn't the initial format equal to MJPG 768x576?
>>>> I would expect that for these boards that should be the default format.
>>>>
>>>> Another issue is that the TODO should mention that for video output there
>>>> should be a second video device node. And that's really something that
>>>> has to be done before the zoran driver can be moved out of staging.
>>>>
>>>> It shouldn't be that hard to implement, I think.
>>>>
>>>> Right now it is impossible to run the compliance test for the output, since
>>>> it doesn't even see it as an output.
>>>>
>>>> Regards,
>>>>
>>>> 	Hans
>>>
>>> I work on having a second device for output, (it is the reason of "staging: media: zoran: move videodev alloc" which will help).
>>>
>>> But I still have the problem of non working output.
>>>
>>> Does output is really needed for going out of staging ?
>>> Probably nobody have it working for ages. The only way to had it was to use an old mplayer output which is broken since so many time.
>>> Note that this plugin will never work again.
>>>
>>> The only way to work on output is to use ffmpeg which just recently have suport for writing non-raw video to V4L.
>>
>> Then just remove it. The code for output remains in the git history so if someone wants to
>> resurrect that, then that's always possible.
>>
>> The point is that I don't want to have half-baked output support in mainline.
>>
>> But what exactly is the problem with getting output to work? Doesn't it just decode
>> MJPEG frames? (Sorry if you explained it before, it's so long ago that I looked at this
>> that I forgot the details)
>>
> 
> The first problem is that zoran dont like comment COM/APP0 markers.
> This imply a per buffer filtering but this is already handled in my next branch.
> 
> But the remaining problem is that any output is like http://kernel.montjoie.ovh/zoran_out.png.
> 
> I hacked the driver to grab a working buffer when doing input and overrun output buffer later.
> And the result is a working static output.
> So the hw handling is good and the problem came from the data feeding/handling.
> 
> I believe that something is wrong in what ffmpeg negociate/send.
> 
> Regards
> 

Why not use v4l2-ctl to capture video and then replay it? You should be able to do this:

v4l2-ctl --stream-mmap --stream-to-hdr cap.hdr --stream-count 60

then this:

v4l2-ctl --stream-out-mmap --stream-from-hdr cap.hdr

The -hdr options write the frames prefixed with a header containing the length of the frame.
That way you can capture variable-length frames and stream them out with the same payload
length.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-09-06 15:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 19:15 [PATCH 0/8] staging: media: zoran: fusion in one module Corentin Labbe
2021-09-03 19:15 ` [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe Corentin Labbe
2021-09-03 19:15 ` [PATCH 2/8] staging: media: zoran: use module_pci_driver Corentin Labbe
2021-09-03 19:15 ` [PATCH 3/8] staging: media: zoran: rename debug module parameter Corentin Labbe
2021-09-03 19:15 ` [PATCH 4/8] staging: media: zoran: add debugfs Corentin Labbe
2021-09-03 23:28   ` kernel test robot
2021-09-03 23:28     ` kernel test robot
2021-09-04  5:53   ` Greg KH
2021-09-06 13:36     ` LABBE Corentin
2021-09-04  6:42   ` kernel test robot
2021-09-04  6:42     ` kernel test robot
2021-09-06 10:20   ` Hans Verkuil
2021-09-03 19:15 ` [PATCH 5/8] staging: media: zoran: videocode: remove procfs Corentin Labbe
2021-09-03 19:15 ` [PATCH 6/8] staging: media: zoran: fusion all modules Corentin Labbe
2021-09-06 10:41   ` Hans Verkuil
2021-09-06 13:40     ` LABBE Corentin
2021-09-03 19:15 ` [PATCH 7/8] staging: media: zoran: remove vidmem Corentin Labbe
2021-09-03 19:15 ` [PATCH 8/8] staging: media: zoran: move videodev alloc Corentin Labbe
2021-09-06 11:03 ` [PATCH 0/8] staging: media: zoran: fusion in one module Hans Verkuil
2021-09-06 13:49   ` LABBE Corentin
2021-09-06 14:11     ` Hans Verkuil
2021-09-06 14:56       ` LABBE Corentin
2021-09-06 15:06         ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.