staging: media: zoran: merge in one module
Subsystems (2)
v4 cover staging: media: zoran: merge in one module
Hello
The main change of this serie is to merge all zoran related modules in one.
This fixes the load order problem when everything is built-in. But this serie include several more fixes found while working on this.
Regards
Changes since v3:
- Fixed a lock up when doing a capture
- added fixes patchs from Hans Verkuil
- dropped DC30 patch, I will send a new patch later for adding DC30D
Changes since v2:
- added the 4 latest patchs
- removed DEBUGFS kconfig option
- fixed Dan Carpenter's reported codec issues
- fixed kernel test robot's reported issues on vb2_dma_contig_set_max_seg_size()
Changes since v1:
- add missing debugfs cleaning
- clean some remaining module_get/put functions which made impossible to remove the zoran module
- added the two latest patchs
Corentin Labbe (14):
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: merge all modules
staging: media: zoran: remove vidmem
staging: media: zoran: move videodev alloc
staging: media: zoran: move config select on primary kconfig
staging: media: zoran: introduce zoran_i2c_init
staging: media: zoran: fix usage of vb2_dma_contig_set_max_seg_size
staging: media: zoran: clean unused code
staging: media: zoran: fix counting buffer in reserve
staging: media: zoran: calculate the right buffer number for
zoran_reap_stat_com
Hans Verkuil (4):
staging: media: zoran: fix various V4L2 compliance errors
staging: media: zoran: fix TRY_FMT handling
staging: media: zoran: drop kernel log spam
staging: media: zoran: drop read/write support
drivers/staging/media/zoran/Kconfig | 38 +- drivers/staging/media/zoran/Makefile | 8 +- drivers/staging/media/zoran/videocodec.c | 68 +--- drivers/staging/media/zoran/videocodec.h | 4 +- drivers/staging/media/zoran/zoran.h | 18 +- drivers/staging/media/zoran/zoran_card.c | 398 +++++++++++++-------- drivers/staging/media/zoran/zoran_device.c | 15 +- drivers/staging/media/zoran/zoran_device.h | 2 - drivers/staging/media/zoran/zoran_driver.c | 56 ++- drivers/staging/media/zoran/zr36016.c | 25 +- drivers/staging/media/zoran/zr36016.h | 2 + drivers/staging/media/zoran/zr36050.c | 24 +- drivers/staging/media/zoran/zr36050.h | 2 + drivers/staging/media/zoran/zr36060.c | 23 +- drivers/staging/media/zoran/zr36060.h | 2 + 15 files changed, 349 insertions(+), 336 deletions(-)
Signature · 1 line
2.32.0
PATCH v4 1/18 staging: media: zoran: move module parameter checks to zoran_probe
We need to empty zoran_init() for removing it later. Furthermore, this permit to use pci_xxx instead of pr_xxx for prettier printing.
--- drivers/staging/media/zoran/zoran_card.c | 64 ++++++++++++------------ 1 file changed, 33 insertions(+), 31 deletions(-)
drivers/staging/media/zoran/zoran_card.c +33 -31
@@ -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" );
Signature · 1 line
2.32.0
PATCH v4 2/18 staging: media: zoran: use module_pci_driver
In reply to Corentin LabbeSimplify code by using module_pci_driver()
--- drivers/staging/media/zoran/zoran_card.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/staging/media/zoran/zoran_card.c +1 -20
@@ -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);
Signature · 1 line
2.32.0
PATCH v4 3/18 staging: media: zoran: rename debug module parameter
In reply to Corentin LabbeAll zoran module will be merged, so to prevent conflict, the debug module parameter need to be renamed
--- 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(-)
drivers/staging/media/zoran/videocodec.c +4 -4
@@ -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)
drivers/staging/media/zoran/zr36016.c +6 -6
@@ -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 );
drivers/staging/media/zoran/zr36050.c +4 -4
@@ -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)
drivers/staging/media/zoran/zr36060.c +4 -5
@@ -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)
Signature · 1 line
2.32.0
PATCH v4 4/18 staging: media: zoran: add debugfs
In reply to Corentin LabbeAdd debugfs for displaying zoran debug and stats information.
--- drivers/staging/media/zoran/Kconfig | 1 + drivers/staging/media/zoran/zoran.h | 2 ++ drivers/staging/media/zoran/zoran_card.c | 36 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+)
drivers/staging/media/zoran/Kconfig +1 -0
@@ -2,6 +2,7 @@ config VIDEO_ZORAN tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)" depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 depends on !ALPHA + depends on DEBUG_FS select VIDEOBUF2_DMA_CONTIG help Say Y for support for MJPEG capture cards based on the Zoran
drivers/staging/media/zoran/zoran.h +2 -0
@@ -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,7 @@ struct zoran {struct list_head queued_bufs;spinlock_t queued_bufs_lock;/* Protects queued_bufs */ struct zr_buffer *inuse[BUZ_NUM_STAT_COM *2 ]; +struct dentry *dbgfs_dir; };static inline struct zoran *to_zoran (struct v4l2_device *v4l2_dev)
drivers/staging/media/zoran/zoran_card.c +36 -0
@@ -945,6 +945,8 @@ static void zoran_remove(struct pci_dev *pdev)if (!zr->initialized) goto exit_free; +debugfs_remove_recursive (zr->dbgfs_dir); +zoran_queue_exit (zr);/* unregister videocodec bus */
@@ -1051,6 +1053,37 @@ static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = { .s_ctrl = zoran_video_set_ctrl, }; +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 %llx\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); +/* * Scan for a Buz card (actually for the PCI controller ZR36057), * request the irq and map the io memory
@@ -1286,6 +1319,9 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr->map_mode =ZORAN_MAP_MODE_RAW ; + zr->dbgfs_dir =debugfs_create_dir (ZR_DEVNAME (zr),NULL ); +debugfs_create_file ("debug" ,0444 , zr->dbgfs_dir, zr, + &zoran_debugfs_fops);return 0 ; zr_detach_vfe:
Signature · 1 line
2.32.0
PATCH v4 5/18 staging: media: zoran: videocode: remove procfs
In reply to Corentin LabbeNow we have a debugfs, we can remove all PROCFS stuff. We keep videocodec_debugfs_show(), it will be used later
--- drivers/staging/media/zoran/videocodec.c | 24 +----------------------- drivers/staging/media/zoran/videocodec.h | 3 +++ 2 files changed, 4 insertions(+), 23 deletions(-)
drivers/staging/media/zoran/videocodec.c +1 -23
@@ -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,7 @@ 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) +int videocodec_debugfs_show (struct seq_file *m) {struct codec_list *h = codeclist_top;struct attached_list *a;
@@ -293,32 +284,19 @@ static int proc_videocodecs_show(struct seq_file *m, void *v)return 0 ; } -#endif /* ===================== */ /* hook in driver module */ /* ===================== */ 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);
drivers/staging/media/zoran/videocodec.h +3 -0
@@ -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,6 @@ extern int videocodec_unregister(const struct videocodec *);/* the other calls are directly done via the videocodec structure! */ +int videocodec_debugfs_show (struct seq_file *m); +#endif /*ifndef __LINUX_VIDEOCODEC_H */
Signature · 1 line
2.32.0
PATCH v4 6/18 staging: media: zoran: merge all modules
In reply to Corentin LabbeThe 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 merge all zoran modules in one.
--- drivers/staging/media/zoran/Kconfig | 14 +-- drivers/staging/media/zoran/Makefile | 8 +- drivers/staging/media/zoran/videocodec.c | 36 +------ drivers/staging/media/zoran/videocodec.h | 1 - drivers/staging/media/zoran/zoran_card.c | 119 +++++++++++++++++++---- drivers/staging/media/zoran/zr36016.c | 13 +-- drivers/staging/media/zoran/zr36016.h | 2 + drivers/staging/media/zoran/zr36050.c | 16 +-- drivers/staging/media/zoran/zr36050.h | 2 + drivers/staging/media/zoran/zr36060.c | 14 +-- drivers/staging/media/zoran/zr36060.h | 2 + 11 files changed, 125 insertions(+), 102 deletions(-)
drivers/staging/media/zoran/Kconfig +7 -7
@@ -15,7 +15,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
@@ -25,7 +25,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.
@@ -33,7 +33,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
@@ -41,7 +41,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
@@ -50,7 +50,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
@@ -59,7 +59,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
@@ -68,7 +68,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
drivers/staging/media/zoran/Makefile +4 -4
@@ -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
drivers/staging/media/zoran/videocodec.c +1 -35
@@ -8,8 +8,6 @@* (c) 2002 Wolfgang Scherr <[email protected]> */ -#define VIDEOCODEC_VERSION "v0.2" -#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h>
@@ -72,12 +70,9 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)if ((master->flags & h->codec->flags) == master->flags) {dprintk (4 ,"%s: try '%s'\n" , __func__, h->codec->name); -if (!try_module_get (h->codec->owner)) -return NULL ; - codec =kmemdup (h->codec,sizeof (struct videocodec ),GFP_KERNEL );if (!codec) - goto out_module_put; + goto out_kfree; res =strlen (codec->name);snprintf (codec->name + res,sizeof (codec->name) - res,"[%d]" , h->attached);
@@ -113,13 +108,10 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)pr_err ("%s: no codec found!\n" , __func__);return NULL ; - out_module_put: -module_put (h->codec->owner); out_kfree:kfree (codec);return NULL ; } -EXPORT_SYMBOL (videocodec_attach);int videocodec_detach (struct videocodec *codec) {
@@ -160,7 +152,6 @@ int videocodec_detach(struct videocodec *codec) prev->next = a->next;dprintk (4 ,"videocodec: delete middle\n" ); } -module_put (a->codec->owner);kfree (a->codec);kfree (a); h->attached -=1 ;
@@ -175,7 +166,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 +198,6 @@ int videocodec_register(const struct videocodec *codec)return 0 ; } -EXPORT_SYMBOL (videocodec_register);int videocodec_unregister (const struct videocodec *codec) {
@@ -255,7 +244,6 @@ int videocodec_unregister(const struct videocodec *codec)pr_err ("%s: given codec not found!\n" , __func__);return -EINVAL ; } -EXPORT_SYMBOL (videocodec_unregister);int videocodec_debugfs_show (struct seq_file *m) {
@@ -284,25 +272,3 @@ int videocodec_debugfs_show(struct seq_file *m)return 0 ; } - -/* ===================== */ -/* 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 <[email protected]>" ); -MODULE_DESCRIPTION ("Intermediate API module for video codecs " -VIDEOCODEC_VERSION ); -MODULE_LICENSE ("GPL" );
drivers/staging/media/zoran/videocodec.h +0 -1
@@ -234,7 +234,6 @@ struct jpeg_app_marker { };struct videocodec { -struct module *owner;/* -- filled in by slave device during register -- */ char name[32 ];unsigned long magic;/* may be used for client<->master attaching */
drivers/staging/media/zoran/zoran_card.c +101 -18
161 lines not on this page · raw message
drivers/staging/media/zoran/zr36016.c +2 -11
@@ -390,7 +390,6 @@ static int zr36016_setup(struct videocodec *codec) }static const struct videocodec zr36016_codec = { - .owner =THIS_MODULE , .name ="zr36016" , .magic =0L ,/* magic not used */ .flags =
@@ -409,14 +408,13 @@ 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 +423,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 <[email protected]>" ); -MODULE_DESCRIPTION ("Driver module for ZR36016 video frontends" ); -MODULE_LICENSE ("GPL" );
drivers/staging/media/zoran/zr36016.h +2 -0
@@ -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 */
drivers/staging/media/zoran/zr36050.c +2 -14
@@ -5,8 +5,6 @@* Copyright (C) 2001 Wolfgang Scherr <[email protected]> */ -#define ZR050_VERSION "v0.7.1" -#include <linux/module.h> #include <linux/init.h> #include <linux/slab.h>
@@ -798,7 +796,6 @@ static int zr36050_setup(struct videocodec *codec) }static const struct videocodec zr36050_codec = { - .owner =THIS_MODULE , .name ="zr36050" , .magic =0L ,// magic not used .flags =
@@ -817,14 +814,13 @@ 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 +829,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 <[email protected]>" ); -MODULE_DESCRIPTION ("Driver module for ZR36050 jpeg processors " -ZR050_VERSION ); -MODULE_LICENSE ("GPL" );
drivers/staging/media/zoran/zr36050.h +2 -0
@@ -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 */
drivers/staging/media/zoran/zr36060.c +2 -12
@@ -5,8 +5,6 @@* Copyright (C) 2002 Laurent Pinchart <[email protected]> */ -#define ZR060_VERSION "v0.7" -#include <linux/module.h> #include <linux/init.h> #include <linux/slab.h>
@@ -831,7 +829,6 @@ static int zr36060_setup(struct videocodec *codec) }static const struct videocodec zr36060_codec = { - .owner =THIS_MODULE , .name ="zr36060" , .magic =0L ,// magic not used .flags =
@@ -846,13 +843,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 +860,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 <[email protected]>" ); -MODULE_DESCRIPTION ("Driver module for ZR36060 jpeg processors " ZR060_VERSION ); -MODULE_LICENSE ("GPL" );
drivers/staging/media/zoran/zr36060.h +2 -0
@@ -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 */
Signature · 1 line
2.32.0
PATCH v4 7/18 staging: media: zoran: remove vidmem
In reply to Corentin LabbeThe vidmem parameter is no longer necessary since we removed framebuffer support.
--- drivers/staging/media/zoran/zoran_card.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/staging/media/zoran/zoran_card.c +0 -15
@@ -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 */
@@ -1218,10 +1207,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 ))
Signature · 1 line
2.32.0
PATCH v4 8/18 staging: media: zoran: move videodev alloc
In reply to Corentin LabbeMove 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.
--- 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(-)
drivers/staging/media/zoran/zoran.h +1 -1
@@ -315,6 +315,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);
drivers/staging/media/zoran/zoran_card.c +50 -30
115 lines not on this page · raw message
drivers/staging/media/zoran/zoran_driver.c +3 -2
@@ -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 );
Signature · 1 line
2.32.0
PATCH v4 9/18 staging: media: zoran: move config select on primary kconfig
In reply to Corentin LabbeSince all kconfigs for card selection are bool, this causes all selected modules to be always built-in.
Prevent this by moving selects to the main tristate kconfig.
By doing this, remove also all "if MEDIA_SUBDRV_AUTOSELECT" which are wrong, since zoran always need them to work.
--- drivers/staging/media/zoran/Kconfig | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/staging/media/zoran/Kconfig +10 -13
@@ -4,6 +4,16 @@ config VIDEO_ZORAN depends on !ALPHA depends on DEBUG_FS select VIDEOBUF2_DMA_CONTIG + select VIDEO_ADV7170 if VIDEO_ZORAN_LML33R10 + select VIDEO_ADV7175 if VIDEO_ZORAN_DC10 || VIDEO_ZORAN_DC30 + select VIDEO_BT819 if VIDEO_ZORAN_LML33 + select VIDEO_BT856 if VIDEO_ZORAN_LML33 || VIDEO_ZORAN_AVS6EYES + select VIDEO_BT866 if VIDEO_ZORAN_AVS6EYES + select VIDEO_KS0127 if VIDEO_ZORAN_AVS6EYES + select VIDEO_SAA711X if VIDEO_ZORAN_BUZ || VIDEO_ZORAN_LML33R10 + select VIDEO_SAA7110 if VIDEO_ZORAN_DC10 + select VIDEO_SAA7185 if VIDEO_ZORAN_BUZ + select VIDEO_VPX3220 if VIDEO_ZORAN_DC30 help Say Y for support for MJPEG capture cards based on the Zoran 36057/36067 PCI controller chipset. This includes the Iomega
@@ -17,8 +27,6 @@ config VIDEO_ZORAN config VIDEO_ZORAN_DC30 bool "Pinnacle/Miro DC30(+) support" depends on VIDEO_ZORAN - select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT - select VIDEO_VPX3220 if MEDIA_SUBDRV_AUTOSELECT help Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback card. This also supports really old DC10 cards based on the
@@ -35,16 +43,12 @@ config VIDEO_ZORAN_ZR36060 config VIDEO_ZORAN_BUZ bool "Iomega Buz support" depends on VIDEO_ZORAN_ZR36060 - select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT - select VIDEO_SAA7185 if MEDIA_SUBDRV_AUTOSELECT help Support for the Iomega Buz MJPEG capture/playback card. config VIDEO_ZORAN_DC10 bool "Pinnacle/Miro DC10(+) support" depends on VIDEO_ZORAN_ZR36060 - select VIDEO_SAA7110 if MEDIA_SUBDRV_AUTOSELECT - select VIDEO_ADV7175 if MEDIA_SUBDRV_AUTOSELECT help Support for the Pinnacle/Miro DC10(+) MJPEG capture/playback card.
@@ -52,8 +56,6 @@ config VIDEO_ZORAN_DC10 config VIDEO_ZORAN_LML33 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 help Support for the Linux Media Labs LML33 MJPEG capture/playback card.
@@ -61,8 +63,6 @@ config VIDEO_ZORAN_LML33 config VIDEO_ZORAN_LML33R10 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 help support for the Linux Media Labs LML33R10 MJPEG capture/playback card.
@@ -70,8 +70,5 @@ config VIDEO_ZORAN_LML33R10 config VIDEO_ZORAN_AVS6EYES bool "AverMedia 6 Eyes support" depends on VIDEO_ZORAN_ZR36060 - select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT - select VIDEO_BT866 if MEDIA_SUBDRV_AUTOSELECT - select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT help Support for the AverMedia 6 Eyes video surveillance card.
Signature · 1 line
2.32.0
PATCH v4 10/18 staging: media: zoran: introduce zoran_i2c_init
In reply to Corentin LabbeReduces the size of the probe function by adding zoran_i2c_init/zoran_i2c_exit functions.
--- drivers/staging/media/zoran/zoran_card.c | 73 ++++++++++++++++++------ 1 file changed, 54 insertions(+), 19 deletions(-)
drivers/staging/media/zoran/zoran_card.c +54 -19
@@ -931,6 +931,53 @@ static int zoran_init_video_devices(struct zoran *zr)return err; } +/* +* v4l2_device_unregister() will care about removing zr->encoder/zr->decoder +* via v4l2_i2c_subdev_unregister() +*/ +static int zoran_i2c_init (struct zoran *zr) +{ +int err; + +pci_info (zr->pci_dev,"Initializing i2c bus...\n" ); + + err =zoran_register_i2c (zr); +if (err) { +pci_err (zr->pci_dev,"%s - cannot initialize i2c bus\n" , __func__); +return err; + } + + zr->decoder =v4l2_i2c_new_subdev (&zr->v4l2_dev, &zr->i2c_adapter, + zr->card.i2c_decoder,0 , + zr->card.addrs_decoder); +if (!zr->decoder) { +pci_err (zr->pci_dev,"Fail to get decoder %s\n" , zr->card.i2c_decoder); + err = -EINVAL ; + goto error_decoder; + } + +if (zr->card.i2c_encoder) { + zr->encoder =v4l2_i2c_new_subdev (&zr->v4l2_dev, &zr->i2c_adapter, + zr->card.i2c_encoder,0 , + zr->card.addrs_encoder); +if (!zr->encoder) { +pci_err (zr->pci_dev,"Fail to get encoder %s\n" , zr->card.i2c_encoder); + err = -EINVAL ; + goto error_decoder; + } + } +return 0 ; + +error_decoder: +zoran_unregister_i2c (zr); +return err; +} + +static void zoran_i2c_exit (struct zoran *zr) +{ +zoran_unregister_i2c (zr); +} +void zoran_open_init_params (struct zoran *zr) {int i;
@@ -1059,7 +1106,7 @@ static void zoran_remove(struct pci_dev *pdev)videocodec_exit (zr);/* unregister i2c bus */ -zoran_unregister_i2c (zr); +zoran_i2c_exit (zr);/* disable PCI bus-mastering */ zoran_set_pci_master (zr,0 );/* put chip into reset */
@@ -1340,22 +1387,10 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }zr36057_restart (zr); -/* i2c */ -pci_info (zr->pci_dev,"Initializing i2c bus...\n" ); -if (zoran_register_i2c (zr) <0 ) { -pci_err (pdev,"%s - can't initialize i2c bus\n" , __func__); + err =zoran_i2c_init (zr); +if (err) goto zr_free_irq; - } - - zr->decoder =v4l2_i2c_new_subdev (&zr->v4l2_dev, &zr->i2c_adapter, - zr->card.i2c_decoder,0 , - zr->card.addrs_decoder); - -if (zr->card.i2c_encoder) - zr->encoder =v4l2_i2c_new_subdev (&zr->v4l2_dev, &zr->i2c_adapter, - zr->card.i2c_encoder,0 , - zr->card.addrs_encoder);pci_info (zr->pci_dev,"Initializing videocodec bus...\n" ); err =videocodec_init (zr);
@@ -1370,15 +1405,15 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (zr->card.video_codec !=0 ) { master_codec =zoran_setup_videocodec (zr, zr->card.video_codec);if (!master_codec) - goto zr_unreg_i2c; + goto zr_unreg_videocodec; zr->codec =videocodec_attach (master_codec);if (!zr->codec) {pci_err (pdev,"%s - no codec found\n" , __func__); - goto zr_unreg_i2c; + goto zr_unreg_videocodec; }if (zr->codec->type != zr->card.video_codec) {pci_err (pdev,"%s - wrong codec\n" , __func__); - goto zr_detach_codec; + goto zr_unreg_videocodec; } }if (zr->card.video_vfe !=0 ) {
@@ -1417,7 +1452,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr_unreg_videocodec:videocodec_exit (zr); zr_unreg_i2c: -zoran_unregister_i2c (zr); +zoran_i2c_exit (zr); zr_free_irq:btwrite (0 ,ZR36057_SPGPPCR );pci_free_irq (zr->pci_dev,0 , zr);
Signature · 1 line
2.32.0
PATCH v4 11/18 staging: media: zoran: fix usage of vb2_dma_contig_set_max_seg_size
In reply to Corentin Labbevb2_dma_contig_set_max_seg_size need to have a size in parameter and not a DMA_BIT_MASK().
While fixing this issue, also fix error handling of all DMA size setting.
--- drivers/staging/media/zoran/zoran_card.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/media/zoran/zoran_card.c +4 -2
@@ -1282,8 +1282,10 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) -return -ENODEV ; -vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); +return err; + err =vb2_dma_contig_set_max_seg_size (&pdev->dev,U32_MAX ); +if (err) +return err; nr = zoran_num++;if (nr >=BUZ_MAX ) {
Signature · 1 line
2.32.0
PATCH v4 12/18 staging: media: zoran: clean unused code
In reply to Corentin LabbeIt remains some unused code from old zoran buffer handling. Let's remove them.
--- drivers/staging/media/zoran/zoran.h | 14 --------- drivers/staging/media/zoran/zoran_card.c | 36 ---------------------- drivers/staging/media/zoran/zoran_device.h | 2 -- drivers/staging/media/zoran/zoran_driver.c | 2 -- 4 files changed, 54 deletions(-)
drivers/staging/media/zoran/zoran.h +0 -14
@@ -54,22 +54,8 @@ static inline struct zr_buffer *vb2_to_zr_buffer(struct vb2_buffer *vb)#define BUZ_NUM_STAT_COM 4#define BUZ_MASK_STAT_COM 3 -#define BUZ_MAX_FRAME 256/* Must be a power of 2 */ -#define BUZ_MASK_FRAME 255/* Must be BUZ_MAX_FRAME-1 */ -#define BUZ_MAX_INPUT 16 -#if VIDEO_MAX_FRAME <=32 -# define V4L_MAX_FRAME 32 -#elif VIDEO_MAX_FRAME <=64 -# define V4L_MAX_FRAME 64 -#else -# error "Too many video frame buffers to handle" -#endif -#define V4L_MASK_FRAME (V4L_MAX_FRAME - 1) - -#define MAX_FRAME (BUZ_MAX_FRAME > VIDEO_MAX_FRAME ? BUZ_MAX_FRAME : VIDEO_MAX_FRAME) -#include "zr36057.h" enum card_type {
drivers/staging/media/zoran/zoran_card.c +0 -36
@@ -60,20 +60,6 @@ static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX - 1)] = -1 };module_param_array (video_nr, int,NULL ,0444 );MODULE_PARM_DESC (video_nr,"Video device number (-1=Auto)" ); -int v4l_nbufs =4 ; -int v4l_bufsize =864 ;/* Everybody should be able to work with this setting */ -module_param (v4l_nbufs, int,0644 ); -MODULE_PARM_DESC (v4l_nbufs,"Maximum number of V4L buffers to use" ); -module_param (v4l_bufsize, int,0644 ); -MODULE_PARM_DESC (v4l_bufsize,"Maximum size per V4L buffer (in kB)" ); - -int jpg_nbufs =32 ; -int jpg_bufsize =512 ;/* max size for 100% quality full-PAL frame */ -module_param (jpg_nbufs, int,0644 ); -MODULE_PARM_DESC (jpg_nbufs,"Maximum number of JPG buffers to use" ); -module_param (jpg_bufsize, int,0644 ); -MODULE_PARM_DESC (jpg_bufsize,"Maximum size per JPG buffer (in kB)" ); -/* 1=Pass through TV signal when device is not used */ /* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */ int pass_through;
@@ -1253,28 +1239,6 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)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 ; -/* 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",
drivers/staging/media/zoran/zoran_device.h +0 -2
@@ -47,9 +47,7 @@ extern void zr36057_restart(struct zoran *zr);extern const struct zoran_format zoran_formats[]; -extern int v4l_nbufs;extern int v4l_bufsize; -extern int jpg_nbufs;extern int jpg_bufsize;extern int pass_through;
drivers/staging/media/zoran/zoran_driver.c +0 -2
@@ -153,8 +153,6 @@ static __u32 zoran_v4l2_calc_bufsize(struct zoran_jpg_settings *settings) result <<=1 ; } -if (result > jpg_bufsize) -return jpg_bufsize;if (result <8192 )return 8192 ;
Signature · 1 line
2.32.0
PATCH v4 13/18 staging: media: zoran: fix counting buffer in reserve
In reply to Corentin LabbeAfter each capture, zoran driver complains that it remains some unused buffer. This is due to a missing count handling.
--- drivers/staging/media/zoran/zoran_driver.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/zoran/zoran_driver.c +1 -0
@@ -887,6 +887,7 @@ int zr_set_buf(struct zoran *zr)return -EINVAL ; }list_del (&buf->queue); + zr->buf_in_reserve--;spin_unlock_irqrestore (&zr->queued_bufs_lock, flags); vbuf = &buf->vbuf;
Signature · 1 line
2.32.0
PATCH v4 14/18 staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com
In reply to Corentin LabbeOn the case tmp_dcim=1, the index of buffer is miscalculated. This generate a NULL pointer dereference later.
So let's fix the calcul and add a check to prevent this to reappear.
--- drivers/staging/media/zoran/zoran_device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/staging/media/zoran/zoran_device.c +6 -1
@@ -814,7 +814,7 @@ static void zoran_reap_stat_com(struct zoran *zr)if (zr->jpg_settings.tmp_dcm ==1 ) i = (zr->jpg_dma_tail - zr->jpg_err_shift) &BUZ_MASK_STAT_COM ;else - i = ((zr->jpg_dma_tail - zr->jpg_err_shift) &1 ) *2 +1 ; + i = ((zr->jpg_dma_tail - zr->jpg_err_shift) &1 ) *2 ; stat_com =le32_to_cpu (zr->stat_com[i]);if ((stat_com &1 ) ==0 ) {
@@ -826,6 +826,11 @@ static void zoran_reap_stat_com(struct zoran *zr) size = (stat_com &GENMASK (22 ,1 )) >>1 ; buf = zr->inuse[i]; +if (!buf) { +spin_unlock_irqrestore (&zr->queued_bufs_lock, flags); +pci_err (zr->pci_dev,"No buffer at slot %d\n" , i); +return ; + } buf->vbuf.vb2_buf.timestamp =ktime_get_ns ();if (zr->codec_mode ==BUZ_MODE_MOTION_COMPRESS ) {
Signature · 1 line
2.32.0
PATCH v4 15/18 staging: media: zoran: fix various V4L2 compliance errors
In reply to Corentin LabbeFrom: Hans Verkuil <[email protected]>
This fixes several issues found with 'v4l2-compliance -s':
1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.
--- drivers/staging/media/zoran/zoran_card.c | 2 +- drivers/staging/media/zoran/zoran_driver.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/staging/media/zoran/zoran_card.c +1 -1
@@ -879,7 +879,7 @@ static int zoran_init_video_device(struct zoran *zr, struct video_device *video_ *video_dev = zoran_template; video_dev->v4l2_dev = &zr->v4l2_dev; video_dev->lock = &zr->lock; - video_dev->device_caps =V4L2_CAP_STREAMING | dir; + video_dev->device_caps =V4L2_CAP_STREAMING |V4L2_CAP_READWRITE | dir;strscpy (video_dev->name,ZR_DEVNAME (zr),sizeof (video_dev->name));/*
drivers/staging/media/zoran/zoran_driver.c +10 -3
@@ -253,8 +253,6 @@ static int zoran_querycap(struct file *file, void *__fh, struct v4l2_capabilitystrscpy (cap->card,ZR_DEVNAME (zr),sizeof (cap->card));strscpy (cap->driver,"zoran" ,sizeof (cap->driver));snprintf (cap->bus_info,sizeof (cap->bus_info),"PCI:%s" ,pci_name (zr->pci_dev)); - cap->device_caps = zr->video_dev->device_caps; - cap->capabilities = cap->device_caps |V4L2_CAP_DEVICE_CAPS ;return 0 ; }
@@ -580,6 +578,9 @@ static int zoran_s_std(struct file *file, void *__fh, v4l2_std_id std)struct zoran *zr =video_drvdata (file);int res =0 ; +if (zr->norm == std) +return 0 ; +if (zr->running !=ZORAN_MAP_MODE_NONE )return -EBUSY ;
@@ -737,6 +738,7 @@ static int zoran_g_parm(struct file *file, void *priv, struct v4l2_streamparm *pif (parm->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )return -EINVAL ; + parm->parm.capture.readbuffers =9 ;return 0 ; }
@@ -867,6 +869,10 @@ int zr_set_buf(struct zoran *zr) vbuf = &buf->vbuf; buf->vbuf.field =V4L2_FIELD_INTERLACED ; +if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height *2 )) + buf->vbuf.field =V4L2_FIELD_INTERLACED ; +else + buf->vbuf.field =V4L2_FIELD_TOP ;vb2_set_plane_payload (&buf->vbuf.vb2_buf,0 , zr->buffer_size);vb2_buffer_done (&buf->vbuf.vb2_buf,VB2_BUF_STATE_DONE ); zr->inuse[0 ] =NULL ;
@@ -927,6 +933,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, unsigned int count) zr->stat_com[j] =cpu_to_le32 (1 ); zr->inuse[j] =NULL ; } + zr->vbseq =0 ;if (zr->map_mode !=ZORAN_MAP_MODE_RAW ) {pci_info (zr->pci_dev,"START JPG\n" );
@@ -1017,7 +1024,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir) vq->dev = &zr->pci_dev->dev; vq->type = dir; - vq->io_modes =VB2_USERPTR |VB2_DMABUF |VB2_MMAP |VB2_READ |VB2_WRITE ; + vq->io_modes =VB2_DMABUF |VB2_MMAP |VB2_READ |VB2_WRITE ; vq->drv_priv = zr; vq->buf_struct_size =sizeof (struct zr_buffer ); vq->ops = &zr_video_qops;
Signature · 1 line
2.32.0
PATCH v4 16/18 staging: media: zoran: fix TRY_FMT handling
In reply to Corentin LabbeFrom: Hans Verkuil <[email protected]>
TRY_FMT must not set actual capture values (zr->buffer_size in this case), since it is a 'try' only.
zoran_try_fmt_vid_cap() also didn't fill in fmt->fmt.pix.bytesperline and fmt->fmt.pix.sizeimage correctly.
--- drivers/staging/media/zoran/zoran_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/zoran/zoran_driver.c +2 -1
@@ -398,7 +398,6 @@ static int zoran_try_fmt_vid_out(struct file *file, void *__fh, V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM); fmt->fmt.pix.sizeimage =zoran_v4l2_calc_bufsize (&settings); - zr->buffer_size = fmt->fmt.pix.sizeimage; fmt->fmt.pix.bytesperline =0 ; fmt->fmt.pix.colorspace =V4L2_COLORSPACE_SMPTE170M ;return res;
@@ -433,6 +432,8 @@ static int zoran_try_fmt_vid_cap(struct file *file, void *__fh, bpp =DIV_ROUND_UP (zoran_formats[i].depth,8 );v4l_bound_align_image (&fmt->fmt.pix.width,BUZ_MIN_WIDTH ,BUZ_MAX_WIDTH , bpp ==2 ?1 :2 , &fmt->fmt.pix.height,BUZ_MIN_HEIGHT ,BUZ_MAX_HEIGHT ,0 ,0 ); + fmt->fmt.pix.bytesperline = fmt->fmt.pix.width * bpp; + fmt->fmt.pix.sizeimage = fmt->fmt.pix.bytesperline * fmt->fmt.pix.height;return 0 ; }
Signature · 1 line
2.32.0
PATCH v4 17/18 staging: media: zoran: drop kernel log spam
In reply to Corentin LabbeFrom: Hans Verkuil <[email protected]>
Do not spam the kernel log with messages that result from incorrect userspace input. Those should be either dropped completely (the error code gives sufficient info) or changed to debug messages.
--- drivers/staging/media/zoran/zoran_device.c | 8 ++++---- drivers/staging/media/zoran/zoran_driver.c | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-)
drivers/staging/media/zoran/zoran_device.c +4 -4
@@ -239,7 +239,7 @@ static void zr36057_set_vfe(struct zoran *zr, int video_width, int video_height, wa = tvn->wa; ha = tvn->ha; -pci_info (zr->pci_dev,"set_vfe() - width = %d, height = %d\n" , video_width, video_height); +pci_dbg (zr->pci_dev,"set_vfe() - width = %d, height = %d\n" , video_width, video_height); if (video_width < BUZ_MIN_WIDTH || video_height < BUZ_MIN_HEIGHT ||
@@ -664,7 +664,7 @@ void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)zr36057_set_jpg (zr, mode);// \P_Reset, ... Video param, FIFO clear_interrupt_counters (zr); -pci_info (zr->pci_dev,"enable_jpg(MOTION_COMPRESS)\n" ); +pci_dbg (zr->pci_dev,"enable_jpg(MOTION_COMPRESS)\n" );break ; }
@@ -693,7 +693,7 @@ void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)zr36057_set_jpg (zr, mode);// \P_Reset, ... Video param, FIFO clear_interrupt_counters (zr); -pci_info (zr->pci_dev,"enable_jpg(MOTION_DECOMPRESS)\n" ); +pci_dbg (zr->pci_dev,"enable_jpg(MOTION_DECOMPRESS)\n" );break ;case BUZ_MODE_IDLE :
@@ -720,7 +720,7 @@ void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)decoder_call (zr, video, s_stream,1 );encoder_call (zr, video, s_routing,0 ,0 ,0 ); -pci_info (zr->pci_dev,"enable_jpg(IDLE)\n" ); +pci_dbg (zr->pci_dev,"enable_jpg(IDLE)\n" );break ; } }
drivers/staging/media/zoran/zoran_driver.c +11 -11
@@ -171,7 +171,7 @@ static int zoran_v4l_set_format(struct zoran *zr, int width, int height,if (height <BUZ_MIN_HEIGHT || width <BUZ_MIN_WIDTH || height >BUZ_MAX_HEIGHT || width >BUZ_MAX_WIDTH ) { -pci_err (zr->pci_dev,"%s - wrong frame size (%dx%d)\n" , __func__, width, height); +pci_dbg (zr->pci_dev,"%s - wrong frame size (%dx%d)\n" , __func__, width, height);return -EINVAL ; }
@@ -181,7 +181,7 @@ static int zoran_v4l_set_format(struct zoran *zr, int width, int height,/* Check against available buffer size */ if (height * width * bpp > zr->buffer_size) { -pci_err (zr->pci_dev,"%s - video buffer size (%d kB) is too small\n" , +pci_dbg (zr->pci_dev,"%s - video buffer size (%d kB) is too small\n" , __func__, zr->buffer_size >>10 );return -EINVAL ; }
@@ -189,7 +189,7 @@ static int zoran_v4l_set_format(struct zoran *zr, int width, int height,/* The video front end needs 4-byte alinged line sizes */ if ((bpp ==2 && (width &1 )) || (bpp ==3 && (width &3 ))) { -pci_err (zr->pci_dev,"%s - wrong frame alignment\n" , __func__); +pci_dbg (zr->pci_dev,"%s - wrong frame alignment\n" , __func__);return -EINVAL ; }
@@ -205,7 +205,7 @@ static int zoran_set_norm(struct zoran *zr, v4l2_std_id norm) {if (!(norm & zr->card.norms)) { -pci_err (zr->pci_dev,"%s - unsupported norm %llx\n" , __func__, norm); +pci_dbg (zr->pci_dev,"%s - unsupported norm %llx\n" , __func__, norm);return -EINVAL ; }
@@ -231,7 +231,7 @@ static int zoran_set_input(struct zoran *zr, int input)return 0 ;if (input <0 || input >= zr->card.inputs) { -pci_err (zr->pci_dev,"%s - unsupported input %d\n" , __func__, input); +pci_dbg (zr->pci_dev,"%s - unsupported input %d\n" , __func__, input);return -EINVAL ; }
@@ -532,7 +532,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,if (fmt->fmt.pix.pixelformat == zoran_formats[i].fourcc)break ;if (i ==NUM_FORMATS ) { -pci_err (zr->pci_dev,"VIDIOC_S_FMT - unknown/unsupported format 0x%x\n" , +pci_dbg (zr->pci_dev,"VIDIOC_S_FMT - unknown/unsupported format 0x%x\n" , fmt->fmt.pix.pixelformat);/* TODO do not return here to fix the TRY_FMT cannot handle an invalid pixelformat*/ return -EINVAL ;
@@ -666,7 +666,7 @@ static int zoran_g_selection(struct file *file, void *__fh, struct v4l2_selectioif (sel->type !=V4L2_BUF_TYPE_VIDEO_OUTPUT && sel->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE ) { -pci_err (zr->pci_dev,"%s invalid selection type combination\n" , __func__); +pci_dbg (zr->pci_dev,"%s invalid selection type combination\n" , __func__);return -EINVAL ; }
@@ -712,7 +712,7 @@ static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selectioreturn -EINVAL ;if (zr->map_mode ==ZORAN_MAP_MODE_RAW ) { -pci_err (zr->pci_dev,"VIDIOC_S_SELECTION - subcapture only supported for compressed capture\n" ); +pci_dbg (zr->pci_dev,"VIDIOC_S_SELECTION - subcapture only supported for compressed capture\n" );return -EINVAL ; }
@@ -937,7 +937,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, unsigned int count) zr->vbseq =0 ;if (zr->map_mode !=ZORAN_MAP_MODE_RAW ) { -pci_info (zr->pci_dev,"START JPG\n" ); +pci_dbg (zr->pci_dev,"START JPG\n" );zr36057_restart (zr);zoran_init_hardware (zr);if (zr->map_mode ==ZORAN_MAP_MODE_JPG_REC )
@@ -951,7 +951,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)return 0 ; } -pci_info (zr->pci_dev,"START RAW\n" ); +pci_dbg (zr->pci_dev,"START RAW\n" );zr36057_restart (zr);zoran_init_hardware (zr);
@@ -1001,7 +1001,7 @@ static void zr_vb2_stop_streaming(struct vb2_queue *vq) }spin_unlock_irqrestore (&zr->queued_bufs_lock, flags);if (zr->buf_in_reserve) -pci_err (zr->pci_dev,"Buffer remaining %d\n" , zr->buf_in_reserve); +pci_dbg (zr->pci_dev,"Buffer remaining %d\n" , zr->buf_in_reserve); zr->map_mode =ZORAN_MAP_MODE_RAW ; }
Signature · 1 line
2.32.0
PATCH v4 18/18 staging: media: zoran: drop read/write support
In reply to Corentin LabbeFrom: Hans Verkuil <[email protected]>
This makes no sense for MJPEG formats and it is just easier to drop support for this altogether.
--- drivers/staging/media/zoran/zoran_card.c | 2 +- drivers/staging/media/zoran/zoran_driver.c | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-)
drivers/staging/media/zoran/zoran_card.c +1 -1
@@ -879,7 +879,7 @@ static int zoran_init_video_device(struct zoran *zr, struct video_device *video_ *video_dev = zoran_template; video_dev->v4l2_dev = &zr->v4l2_dev; video_dev->lock = &zr->lock; - video_dev->device_caps =V4L2_CAP_STREAMING |V4L2_CAP_READWRITE | dir; + video_dev->device_caps =V4L2_CAP_STREAMING | dir;strscpy (video_dev->name,ZR_DEVNAME (zr),sizeof (video_dev->name));/*
drivers/staging/media/zoran/zoran_driver.c +0 -12
@@ -734,15 +734,6 @@ static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selectioreturn res; } -static int zoran_g_parm (struct file *file,void *priv,struct v4l2_streamparm *parm) -{ -if (parm->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE ) -return -EINVAL ; - - parm->parm.capture.readbuffers =9 ; -return 0 ; -} -/* * Output is disabled temporarily * Zoran is picky about jpeg data it accepts. At least it seems to unsupport COM and APPn.
@@ -750,7 +741,6 @@ static int zoran_g_parm(struct file *file, void *priv, struct v4l2_streamparm *p*/ static const struct v4l2_ioctl_ops zoran_ioctl_ops = { .vidioc_querycap = zoran_querycap, - .vidioc_g_parm = zoran_g_parm, .vidioc_s_selection = zoran_s_selection, .vidioc_g_selection = zoran_g_selection, .vidioc_enum_input = zoran_enum_input,
@@ -786,8 +776,6 @@ static const struct v4l2_file_operations zoran_fops = { .unlocked_ioctl = video_ioctl2, .open = v4l2_fh_open, .release = vb2_fop_release, - .read = vb2_fop_read, - .write = vb2_fop_write, .mmap = vb2_fop_mmap, .poll = vb2_fop_poll, };
Signature · 1 line
2.32.0