[Mjpeg-users] [PATCH 3/8] staging: media: zoran: rename debug module parameter

2021-09-03 Thread 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 
---
 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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 7/8] staging: media: zoran: remove vidmem

2021-09-03 Thread Corentin Labbe
The vidmem parameter is no longer necessary since we removed framebuffer
support.

Signed-off-by: Corentin Labbe 
---
 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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 2/8] staging: media: zoran: use module_pci_driver

2021-09-03 Thread Corentin Labbe
Simplify code by using module_pci_driver()

Signed-off-by: Corentin Labbe 
---
 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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


Re: [Mjpeg-users] [PATCH 4/8] staging: media: zoran: add debugfs

2021-09-03 Thread kernel test robot
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 

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-...@lists.01.org


.config.gz
Description: application/gzip
___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 6/8] staging: media: zoran: fusion all modules

2021-09-03 Thread 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 
---
 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 
  */
 
-#define VIDEOCODEC_VERSION "v0.2"
-
 #include 
 #include 
 #include 
@@ -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 +2

[Mjpeg-users] [PATCH 1/8] staging: media: zoran: move module parameter checks to zoran_probe

2021-09-03 Thread 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 
---
 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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 8/8] staging: media: zoran: move videodev alloc

2021-09-03 Thread 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 
---
 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 * size

[Mjpeg-users] [PATCH 4/8] staging: media: zoran: add debugfs

2021-09-03 Thread Corentin Labbe
Add debugfs for displaying zoran debug and stats information.

Signed-off-by: Corentin Labbe 
---
 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 
 #include 
 #include 
 #include 
@@ -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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 5/8] staging: media: zoran: videocode: remove procfs

2021-09-03 Thread 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 
---
 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 
 #include 
 
-// kernel config is here (procfs flag)
-
-#ifdef CONFIG_PROC_FS
-#include 
-#include 
-#include 
-#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 c001  
(zr36050[1])
 #ifndef __LINUX_VIDEOCODEC_H
 #define __LINUX_VIDEOCODEC_H
 
+#include 
 #include 
 
 #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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 0/8] staging: media: zoran: fusion in one module

2021-09-03 Thread 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



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users