media: Introduce video device state management
Subsystems (141)
v2 cover media: Introduce video device state management
Hi,
This patch series introduces state management for video devices.
Currently, V4L2 subdevices have a well-established state management system [1] that allows the framework to store the subdevice state at a central location.
Video devices however lack this, leading to inconsistent state handling across drivers and making it difficult to implement features like hardware multiplexing in complex media pipelines [2].
The series is composed of three parts:
- Core Infrastructure (PATCH 1-4)
Introduces the basic state structure, try state support, initialization callbacks, and driver helpers
- Framework Integration (PATCH 5-7)
Integrates state passing through the ioctl wrappers and driver implementations
- Driver Examples (PATCH 8-10)
Use the state to store formats in TI J721E CSI2RX and Rockchip RKISP1 drivers
This should also provide a foundation for drivers to extend or subclass the state structure with device-specific variables in future.
I have tested capture and format negotiation with the converted drivers on SK AM62A (j721e-csi2rx) and Debix Model A (rkisp1).
[1]: https://lore.kernel.org/linux-media/[email protected]/
[2]: https://lore.kernel.org/linux-media/20250724-multicontext-mainline-2025-v2-0-c9b316773486@ideasonboard.com/
---
Changes in v2:
- Drop RFC tag
- Rebase on top of latest media tree, that includes multiple changes by
Jacopo and Laurent, which removes all usage of passing v4l2_fh through
the opaque pointer in ioctl implementations, replacing it with a NULL
pointer
- Allocate the state dynamically, and free it when done with the device
or the filehandle
- Introduce an init_state callback so that drivers can initialize the
state after allocation
- Pass the video device state (as an explicitly typed pointer) to all
ioctl implemenation across all drivers
- Split the single patch introducing video device state into separate
patches each making a single logical change before the state is
actually passed to the drivers in PATCH 7
- In drivers, use a helper to access the current format from the state
- Move the queue busy check back to the drivers, as some codecs and VBI
devices may support changing formats, so the framework shouldn't
return -EBUSY
- Drop pixel format info and configuration storage from rkisp1 internal strucutre, and calculate them on the fly
- Fix other review comments from Sakari, Laurent and Jacopo, except
those around dropping the enum and using try_fmt hook to update only
the state, and s_fmt hook to update hardware registers
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jai Luthra (10):
media: v4l2-core: Introduce state management for video devices
media: v4l2-dev: Add support for try state
media: v4l2-dev: Add callback for initializing video device state
media: v4l2-dev: Add helpers to get current format from the state
media: v4l2-ioctl: Add video_device_state argument to v4l2 ioctl wrappers
media: Replace void * with video_device_state * in all driver ioctl implementations
media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls
media: ti: j721e-csi2rx: Use video_device_state
media: rkisp1: Use video_device_state
media: rkisp1: Calculate format information on demand
drivers/input/rmi4/rmi_f54.c | 22 +- drivers/input/touchscreen/atmel_mxt_ts.c | 23 +- drivers/input/touchscreen/sur40.c | 35 +- .../extron-da-hd-4k-plus/extron-da-hd-4k-plus.c | 34 +- drivers/media/common/saa7146/saa7146_video.c | 37 +- drivers/media/common/videobuf2/videobuf2-v4l2.c | 30 +- drivers/media/dvb-frontends/rtl2832_sdr.c | 38 +- drivers/media/i2c/video-i2c.c | 39 ++- drivers/media/pci/bt8xx/bttv-driver.c | 84 +++-- drivers/media/pci/bt8xx/bttv-vbi.c | 11 +- drivers/media/pci/bt8xx/bttvp.h | 9 +- drivers/media/pci/cobalt/cobalt-v4l2.c | 98 +++--- drivers/media/pci/cx18/cx18-driver.c | 9 +- drivers/media/pci/cx18/cx18-ioctl.c | 114 +++--- drivers/media/pci/cx18/cx18-ioctl.h | 9 +- drivers/media/pci/cx23885/cx23885-417.c | 53 +-- drivers/media/pci/cx23885/cx23885-ioctl.c | 8 +- drivers/media/pci/cx23885/cx23885-ioctl.h | 9 +- drivers/media/pci/cx23885/cx23885-vbi.c | 5 +- drivers/media/pci/cx23885/cx23885-video.c | 82 +++-- drivers/media/pci/cx23885/cx23885.h | 4 +- drivers/media/pci/cx25821/cx25821-video.c | 57 ++- drivers/media/pci/cx88/cx88-blackbird.c | 47 ++- drivers/media/pci/cx88/cx88-vbi.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 56 ++- drivers/media/pci/cx88/cx88.h | 2 +- drivers/media/pci/dt3155/dt3155.c | 25 +- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 29 +- drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 41 ++- drivers/media/pci/ivtv/ivtv-driver.c | 8 +- drivers/media/pci/ivtv/ivtv-ioctl.c | 225 ++++++++---- drivers/media/pci/ivtv/ivtv-ioctl.h | 6 +- drivers/media/pci/mgb4/mgb4_vin.c | 55 ++- drivers/media/pci/mgb4/mgb4_vout.c | 49 ++- drivers/media/pci/saa7134/saa7134-empress.c | 12 +- drivers/media/pci/saa7134/saa7134-video.c | 96 ++++-- drivers/media/pci/saa7134/saa7134.h | 38 +- drivers/media/pci/saa7146/hexium_gemini.c | 10 +- drivers/media/pci/saa7146/hexium_orion.c | 10 +- drivers/media/pci/saa7146/mxb.c | 46 ++- drivers/media/pci/saa7164/saa7164-encoder.c | 39 ++- drivers/media/pci/saa7164/saa7164-vbi.c | 27 +- drivers/media/pci/saa7164/saa7164.h | 9 +- drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 46 ++- drivers/media/pci/solo6x10/solo6x10-v4l2.c | 32 +- drivers/media/pci/ttpci/budget-av.c | 10 +- drivers/media/pci/tw5864/tw5864-video.c | 49 ++- drivers/media/pci/tw68/tw68-video.c | 43 ++- drivers/media/pci/tw686x/tw686x-video.c | 53 ++- drivers/media/pci/zoran/zoran_driver.c | 44 ++- drivers/media/platform/allegro-dvt/allegro-core.c | 49 ++- .../media/platform/amlogic/c3/isp/c3-isp-capture.c | 18 +- .../media/platform/amlogic/c3/isp/c3-isp-params.c | 9 +- .../media/platform/amlogic/c3/isp/c3-isp-stats.c | 9 +- drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 36 +- drivers/media/platform/amphion/vdec.c | 30 +- drivers/media/platform/amphion/venc.c | 49 ++- drivers/media/platform/aspeed/aspeed-video.c | 50 ++- drivers/media/platform/atmel/atmel-isi.c | 36 +- drivers/media/platform/broadcom/bcm2835-unicam.c | 33 +- .../media/platform/chips-media/coda/coda-common.c | 69 ++-- .../platform/chips-media/wave5/wave5-helper.c | 2 +- .../platform/chips-media/wave5/wave5-helper.h | 3 +- .../platform/chips-media/wave5/wave5-vpu-dec.c | 54 ++- .../platform/chips-media/wave5/wave5-vpu-enc.c | 62 +++- .../media/platform/imagination/e5010-jpeg-enc.c | 34 +- drivers/media/platform/intel/pxa_camera.c | 34 +- drivers/media/platform/m2m-deinterlace.c | 34 +- drivers/media/platform/marvell/mcam-core.c | 52 +-- .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 44 ++- drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 34 +- .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 25 +- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 52 ++- .../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 50 ++- .../media/platform/microchip/microchip-isc-base.c | 33 +- drivers/media/platform/nuvoton/npcm-video.c | 43 ++- drivers/media/platform/nvidia/tegra-vde/v4l2.c | 38 +- drivers/media/platform/nxp/dw100/dw100.c | 35 +- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 52 ++- drivers/media/platform/nxp/imx-pxp.c | 34 +- drivers/media/platform/nxp/imx7-media-csi.c | 21 +- drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 15 +- .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 18 +- drivers/media/platform/nxp/mx2_emmaprp.c | 31 +- drivers/media/platform/qcom/camss/camss-video.c | 27 +- drivers/media/platform/qcom/iris/iris_vidc.c | 48 ++- drivers/media/platform/qcom/venus/vdec.c | 29 +- drivers/media/platform/qcom/venus/venc.c | 38 +- .../media/platform/raspberrypi/pisp_be/pisp_be.c | 42 ++- drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 40 ++- .../media/platform/renesas/rcar-vin/rcar-v4l2.c | 21 +- drivers/media/platform/renesas/rcar_drif.c | 30 +- drivers/media/platform/renesas/rcar_fdp1.c | 18 +- drivers/media/platform/renesas/rcar_jpu.c | 21 +- drivers/media/platform/renesas/renesas-ceu.c | 36 +- .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 18 +- drivers/media/platform/renesas/sh_vou.c | 41 ++- drivers/media/platform/renesas/vsp1/vsp1_histo.c | 9 +- drivers/media/platform/renesas/vsp1/vsp1_video.c | 18 +- drivers/media/platform/rockchip/rga/rga.c | 24 +- .../platform/rockchip/rkisp1/rkisp1-capture.c | 289 ++++++++-------- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 10 - .../media/platform/rockchip/rkisp1/rkisp1-params.c | 15 +- .../media/platform/rockchip/rkisp1/rkisp1-stats.c | 9 +- drivers/media/platform/rockchip/rkvdec/rkvdec.c | 34 +- .../media/platform/samsung/exynos-gsc/gsc-m2m.c | 44 ++- .../platform/samsung/exynos4-is/fimc-capture.c | 45 ++- .../platform/samsung/exynos4-is/fimc-isp-video.c | 32 +- .../media/platform/samsung/exynos4-is/fimc-lite.c | 36 +- .../media/platform/samsung/exynos4-is/fimc-m2m.c | 21 +- .../platform/samsung/s3c-camif/camif-capture.c | 54 ++- drivers/media/platform/samsung/s5p-g2d/g2d.c | 26 +- .../media/platform/samsung/s5p-jpeg/jpeg-core.c | 34 +- .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 48 ++- .../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 51 ++- drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 26 +- drivers/media/platform/st/sti/delta/delta-v4l2.c | 44 ++- drivers/media/platform/st/sti/hva/hva-v4l2.c | 46 ++- drivers/media/platform/st/stm32/dma2d/dma2d.c | 18 +- drivers/media/platform/st/stm32/stm32-dcmi.c | 42 ++- .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 20 +- .../media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 25 +- .../platform/sunxi/sun6i-csi/sun6i_csi_capture.c | 24 +- drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 31 +- .../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 34 +- .../media/platform/synopsys/hdmirx/snps_hdmirx.c | 47 ++- drivers/media/platform/ti/am437x/am437x-vpfe.c | 52 ++- drivers/media/platform/ti/cal/cal-video.c | 54 ++- drivers/media/platform/ti/davinci/vpif_capture.c | 94 ++--- drivers/media/platform/ti/davinci/vpif_display.c | 58 ++-- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 127 +++---- drivers/media/platform/ti/omap/omap_vout.c | 49 ++- drivers/media/platform/ti/omap3isp/ispvideo.c | 53 ++- drivers/media/platform/ti/vpe/vpe.c | 25 +- drivers/media/platform/verisilicon/hantro_v4l2.c | 47 ++- drivers/media/platform/via/via-camera.c | 42 ++- drivers/media/platform/xilinx/xilinx-dma.c | 15 +- drivers/media/radio/dsbr100.c | 15 +- drivers/media/radio/radio-cadet.c | 18 +- drivers/media/radio/radio-isa.c | 18 +- drivers/media/radio/radio-keene.c | 15 +- drivers/media/radio/radio-ma901.c | 15 +- drivers/media/radio/radio-miropcm20.c | 15 +- drivers/media/radio/radio-mr800.c | 18 +- drivers/media/radio/radio-raremono.c | 19 +- drivers/media/radio/radio-sf16fmi.c | 15 +- drivers/media/radio/radio-si476x.c | 28 +- drivers/media/radio/radio-tea5764.c | 15 +- drivers/media/radio/radio-tea5777.c | 21 +- drivers/media/radio/radio-timb.c | 26 +- drivers/media/radio/si470x/radio-si470x-common.c | 25 +- drivers/media/radio/si4713/radio-platform-si4713.c | 18 +- drivers/media/radio/si4713/radio-usb-si4713.c | 15 +- drivers/media/radio/tea575x.c | 21 +- drivers/media/test-drivers/vicodec/vicodec-core.c | 54 +-- drivers/media/test-drivers/vim2m.c | 56 +-- drivers/media/test-drivers/vimc/vimc-capture.c | 20 +- drivers/media/test-drivers/visl/visl-video.c | 34 +- drivers/media/test-drivers/vivid/vivid-core.c | 203 ++++++----- drivers/media/test-drivers/vivid/vivid-meta-cap.c | 6 +- drivers/media/test-drivers/vivid/vivid-meta-cap.h | 6 +- drivers/media/test-drivers/vivid/vivid-meta-out.c | 6 +- drivers/media/test-drivers/vivid/vivid-meta-out.h | 9 +- drivers/media/test-drivers/vivid/vivid-radio-rx.c | 16 +- drivers/media/test-drivers/vivid/vivid-radio-rx.h | 16 +- drivers/media/test-drivers/vivid/vivid-radio-tx.c | 6 +- drivers/media/test-drivers/vivid/vivid-radio-tx.h | 6 +- drivers/media/test-drivers/vivid/vivid-sdr-cap.c | 30 +- drivers/media/test-drivers/vivid/vivid-sdr-cap.h | 30 +- drivers/media/test-drivers/vivid/vivid-touch-cap.c | 22 +- drivers/media/test-drivers/vivid/vivid-touch-cap.h | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-cap.c | 26 +- drivers/media/test-drivers/vivid/vivid-vbi-cap.h | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-out.c | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-out.h | 18 +- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 114 +++--- drivers/media/test-drivers/vivid/vivid-vid-cap.h | 117 +++++-- .../media/test-drivers/vivid/vivid-vid-common.c | 24 +- .../media/test-drivers/vivid/vivid-vid-common.h | 34 +- drivers/media/test-drivers/vivid/vivid-vid-out.c | 122 ++++--- drivers/media/test-drivers/vivid/vivid-vid-out.h | 95 +++-- drivers/media/usb/airspy/airspy.c | 37 +- drivers/media/usb/au0828/au0828-video.c | 74 ++-- drivers/media/usb/cx231xx/cx231xx-417.c | 28 +- drivers/media/usb/cx231xx/cx231xx-video.c | 79 +++-- drivers/media/usb/cx231xx/cx231xx.h | 39 ++- drivers/media/usb/dvb-usb/cxusb-analog.c | 48 ++- drivers/media/usb/em28xx/em28xx-video.c | 87 +++-- drivers/media/usb/go7007/go7007-v4l2.c | 75 ++-- drivers/media/usb/gspca/gspca.c | 51 ++- drivers/media/usb/hackrf/hackrf.c | 39 ++- drivers/media/usb/hdpvr/hdpvr-video.c | 60 ++-- drivers/media/usb/msi2500/msi2500.c | 31 +- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 98 ++++-- drivers/media/usb/pwc/pwc-v4l.c | 44 ++- drivers/media/usb/s2255/s2255drv.c | 55 ++- drivers/media/usb/stk1160/stk1160-v4l.c | 40 ++- drivers/media/usb/usbtv/usbtv-video.c | 24 +- drivers/media/usb/uvc/uvc_metadata.c | 17 +- drivers/media/usb/uvc/uvc_v4l2.c | 59 +++- drivers/media/v4l2-core/v4l2-ctrls-api.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 66 ++++ drivers/media/v4l2-core/v4l2-fh.c | 6 + drivers/media/v4l2-core/v4l2-ioctl.c | 381 +++++++++++---------- drivers/media/v4l2-core/v4l2-mem2mem.c | 56 +-- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 72 ++-- drivers/staging/media/av7110/av7110_v4l.c | 60 +++- .../media/deprecated/atmel/atmel-isc-base.c | 33 +- drivers/staging/media/imx/imx-media-capture.c | 53 ++- drivers/staging/media/imx/imx-media-csc-scaler.c | 23 +- drivers/staging/media/ipu3/ipu3-v4l2.c | 29 +- drivers/staging/media/ipu7/ipu7-isys-video.c | 30 +- drivers/staging/media/meson/vdec/vdec.c | 26 +- drivers/staging/media/starfive/camss/stf-video.c | 18 +- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 29 +- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 24 +- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 9 +- drivers/staging/media/tegra-video/vi.c | 68 ++-- drivers/staging/most/video/video.c | 39 ++- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 58 ++-- drivers/usb/gadget/function/uvc_v4l2.c | 50 ++- include/media/v4l2-ctrls.h | 5 +- include/media/v4l2-dev.h | 84 +++++ include/media/v4l2-fh.h | 2 + include/media/v4l2-ioctl.h | 238 ++++++------- include/media/v4l2-mem2mem.h | 48 ++- include/media/videobuf2-v4l2.h | 33 +- 227 files changed, 5946 insertions(+), 3322 deletions(-)
---
base-commit: 680fa38ea3a19131871a90bac05a610e6247d928
change-id: 20250703-vdev-state-0743baa0ad4b
Best regards,
Signature · 1 line
Jai Luthra <[email protected]>
PATCH v2 1/10 media: v4l2-core: Introduce state management for video devices
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the video_device structure.
This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +27 -0
@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);
@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :
@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);
include/media/v4l2-dev.h +40 -0
@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */
@@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *); }; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt; +struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to
@@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m
@@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];
@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Signature · 1 line
2.51.0
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);
include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;
While typically a video_device supports only a single video format type, that is not always the case. There are the following exceptions:
1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a video_device_state struct anyway.
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
4) video devices can also support an OVERLAY or OUTPUT_OVERLAY format (rare)
V4L2_CAP_VIDEO_OVERLAY is currently only used in drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in video_device anyway.
But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct v4l2_fh or struct video_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Quoted 142 lines · Hans Verkuil
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
4) video devices can also support an OVERLAY orOUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.
Quoted 7 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming video_device_state since it isn't video_device specific, i.e. it can either live in video_device or in v4l2_fh, and in the latter case you'd have two instances: capture and output state.
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Hi Hans,
Thanks for the review.
Quoting Hans Verkuil (2025-09-22 13:30:05)
Quoted 131 lines · Hans Verkuil
Quoted 130 lines
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:
Quoted 3 lines
Quoted 3 lines
1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.
Ah I see, so for M2M devices the formats are stored per-context, where the context is tied to the filehandle. In that case, I agree that storing the format state inside struct video_device would not work.
Quoted 3 lines
Quoted 3 lines
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
RPi CFE driver is one such case, where a single driver structure stores both metadata and video format. But if I understand correctly, it creates separate video device nodes for metadata and video capture, so it can be managed through a single v4l2_format.fmt union for each video device.
Are there any non-M2M drivers which allow more than one type of formats to be set on the same device node?
Quoted 5 lines
Quoted 5 lines
4) video devices can also support an OVERLAY or
OUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.
Yes, bcm2835-camera should be dropped hopefully in a couple more revisions of
https://lore.kernel.org/all/[email protected]/
Quoted 8 lines
Quoted 8 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.
Sure, I think we can modify the existing state struct to store both capture and output formats, and keep it inside struct v4l2_fh for M2M devices.
This will definitely be confusing for driver developers, as currently the two example patches in this series access the state directly. So I will add framework helpers to access the correct state and format type, and document properly that it should never be accessed manually by drivers.
Quoted 5 lines
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming
video_device_statesince it isn'tvideo_devicespecific, i.e. it can either live invideo_deviceor inv4l2_fh, and in the latter case you'd have two instances: capture and output state.
Argh, naming is the hardest problem :-)
Do you have any suggestions?
I personally don't think video_device_state is a bad name, even if it is stored somewhere else for m2m devices, given it is still the "state" of the video device, even if it is not persistent across multiple file opens.
I was trying to avoid names with "context" in then, so it does not clash with Jacopo's work.
Quoted 64 lines
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Thanks,
Jai
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Hi Jai,
Thanks for your efforts! Could you include me in Cc: in the next iteration, please?
Quoted 28 lines · Jai Luthra
Hi Hans,
Thanks for the review.
Quoting Hans Verkuil (2025-09-22 13:30:05)
Quoted 23 lines · Hans Verkuil
Quoted 22 lines
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 17 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Could you elaborate a bit on how (sub)device states and the future contexts will be related? Based on the description above, I imagine that at some point there will be a context data structure that contains all (sub) device states, and when a certain context becomes active, the states are passed and applied to the (sub)devices. But this is only my imagination here. It would be great to know the overall concept here.
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *); };
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/media/v4l2-dev.h struct v4l2_file_operations { · line 227
Quoted 5 lines
include/media/v4l2-dev.h +5
-0+/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device
What else do you envisage to be included in the state?
Quoted 45 lines
Quoted 10 lines
Quoted 10 lines
include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 3 lines
include/media/v4l2-dev.h +3
-0+*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.Ah I see, so for M2M devices the formats are stored per-context, where the context is tied to the filehandle. In that case, I agree that storing the format state inside struct
video_devicewould not work.Quoted 3 lines
Quoted 3 lines
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.RPi CFE driver is one such case, where a single driver structure stores both metadata and video format. But if I understand correctly, it creates separate video device nodes for metadata and video capture, so it can be managed through a single v4l2_format.fmt union for each video device.
Are there any non-M2M drivers which allow more than one type of formats to be set on the same device node?
Quoted 5 lines
Quoted 5 lines
4) video devices can also support an OVERLAY or
OUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.Yes, bcm2835-camera should be dropped hopefully in a couple more revisions of
https://lore.kernel.org/all/[email protected]/Quoted 8 lines
Quoted 8 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.
Quoted 7 lines
Sure, I think we can modify the existing state struct to store both capture and output formats, and keep it inside struct
v4l2_fhfor M2M devices.This will definitely be confusing for driver developers, as currently the two example patches in this series access the state directly. So I will add framework helpers to access the correct state and format type, and document properly that it should never be accessed manually by drivers.
Would that be a similar approach as in v4l2_subdev_state?
Quoted 8 lines
Quoted 4 lines
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming
video_device_statesince it isn'tvideo_devicespecific, i.e. it can either live invideo_deviceor inv4l2_fh, and in the latter case you'd have two instances: capture and output state.Argh, naming is the hardest problem :-)
Do you have any suggestions?
Quoted 6 lines
I personally don't think
video_device_stateis a bad name, even if it is stored somewhere else for m2m devices, given it is still the "state" of the video device, even if it is not persistent across multiple file opens.I was trying to avoid names with "context" in then, so it does not clash with Jacopo's work.
It would be interesting how contexts (the new ones from Jacopo's series) are applied to mem2mem devices. And again, how the state introduced here is related to the (new) context.
Best regards,
Michael
Quoted 69 lines
Quoted 65 lines
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir * Thanks,
Jai
Jacopo Mondi
maintainerRe: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Hi Michael
Quoted 29 lines · Michael Riesch
Hi Jai,
Thanks for your efforts! Could you include me in Cc: in the next iteration, please?
Quoted 23 lines · Jai Luthra
Hi Hans,
Thanks for the review.
Quoting Hans Verkuil (2025-09-22 13:30:05)
Quoted 18 lines · Hans Verkuil
Quoted 17 lines
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 12 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Could you elaborate a bit on how (sub)device states and the future
Quoted 3 lines
contexts will be related? Based on the description above, I imagine that at some point there will be a context data structure that contains all (sub) device states, and when a certain context becomes active, the
Not all states, a single state.
There will be
1) One state per context
2) One state per open-file handle
3) One state per subdevice
If the driver supports contexts 1) will be used for active and 2) for try.
If the driver doesn't support contexts 3) will be used for activer and
2) for try.
It's a bit more complex than this as we also have a default context in the subdev to support drivers that are context-aware but are operated by context-unaware userspace.
Happy to discuss this more on the actual context series.
Quoted 254 lines
states are passed and applied to the (sub)devices. But this is only my imagination here. It would be great to know the overall concept here.
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *); };Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/media/v4l2-dev.h struct v4l2_file_operations { · line 227
Quoted 5 lines
include/media/v4l2-dev.h +5
-0+/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device What else do you envisage to be included in the state?
Quoted 45 lines
Quoted 10 lines
Quoted 10 lines
include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 3 lines
include/media/v4l2-dev.h +3
-0+*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.Ah I see, so for M2M devices the formats are stored per-context, where the context is tied to the filehandle. In that case, I agree that storing the format state inside struct
video_devicewould not work.Quoted 3 lines
Quoted 3 lines
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.RPi CFE driver is one such case, where a single driver structure stores both metadata and video format. But if I understand correctly, it creates separate video device nodes for metadata and video capture, so it can be managed through a single v4l2_format.fmt union for each video device.
Are there any non-M2M drivers which allow more than one type of formats to be set on the same device node?
Quoted 5 lines
Quoted 5 lines
4) video devices can also support an OVERLAY or
OUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.Yes, bcm2835-camera should be dropped hopefully in a couple more revisions of
https://lore.kernel.org/all/[email protected]/Quoted 8 lines
Quoted 8 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.Quoted 7 lines
Sure, I think we can modify the existing state struct to store both capture and output formats, and keep it inside struct
v4l2_fhfor M2M devices.This will definitely be confusing for driver developers, as currently the two example patches in this series access the state directly. So I will add framework helpers to access the correct state and format type, and document properly that it should never be accessed manually by drivers.
Would that be a similar approach as in
v4l2_subdev_state?Quoted 8 lines
Quoted 4 lines
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming
video_device_statesince it isn'tvideo_devicespecific, i.e. it can either live invideo_deviceor inv4l2_fh, and in the latter case you'd have two instances: capture and output state.Argh, naming is the hardest problem :-)
Do you have any suggestions?Quoted 6 lines
I personally don't think
video_device_stateis a bad name, even if it is stored somewhere else for m2m devices, given it is still the "state" of the video device, even if it is not persistent across multiple file opens.I was trying to avoid names with "context" in then, so it does not clash with Jacopo's work.
It would be interesting how contexts (the new ones from Jacopo's series) are applied to mem2mem devices. And again, how the state introduced here is related to the (new) context.
Best regards,
MichaelQuoted 69 lines
Quoted 65 lines
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir * Thanks,
Jai
Jacopo Mondi
maintainerRe: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
In reply to Jai LuthraHi Jai, Hans
Quoted 136 lines · Jai Luthra
Hi Hans,
Thanks for the review.
Quoting Hans Verkuil (2025-09-22 13:30:05)
Quoted 131 lines · Hans Verkuil
Quoted 130 lines
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.Ah I see, so for M2M devices the formats are stored per-context, where the context is tied to the filehandle. In that case, I agree that storing the format state inside struct
video_devicewould not work.
The m2m frameworks stores in 'struct v4l2_m2m_ctx' two queue contexts, one for the output queue and one for capture queue. A v4l2_m2m_ctx is created every time the video device is open and the two queues initialized. Userspace opens the video device two (or more) times and one of the two contexts is used at a time depending on the buffer type userspace uses to initialize the device.
The right place where to store the 'state' seems to me to be 'struct v4l2_m2m_queue_ctx' and a set of helpers for m2m should be provided for drivers to be able to get the 'capture' or 'output' format, provided a v4l2_m2m_ctx to operate with and the buffer type in use.
I'm looking at the m2m driver I know the better (imx8-isi-m2m.c) and the conversion seems trivial there. The format information stored as ctx->queues.out.format/ctx->queues.cap.format could be moved to the framework and accessed with helpers by the driver. As soon as we allow drivers to sub-class the video device state (something I think we should do from the very beginning in this series) the whole 'struct mxc_isi_m2m_ctx_queue_data' type can be replaced and become 'struct mxc_isi_m2m_ctx_state'.
M2M drivers will not set V4L2_FL_USES_STATE so there won't be a state stored in the file handle or the video device for them, but we can indeed require m2m drivers to provide an 'init_state' operation like we do for regular video devices, where the state will be initialised. Only new drivers that provide such operation will have a centralized state.
Now, what do we gain here ? The current video_device_state stores a v4l2_format and a video_device *, and only the v4l2_format is relevant for the m2m framework [*]. However centralizing storage of the format in the framwork and allowing drivers to sub-class it would save some boilerplate indeed. I would be happy to try do this on imx8-isi-m2m.c to see how it will look like.
[*] I would be tempted to introduce a 'class' hierarchy such as:
struct v4l2_device_state {
struct v4l2_format fmt;
}
struct video_device_state {
struct v4l2_device_state state;
struct video_device *vdev;
}
struct m2m_context_state {
struct v4l2_device_state state;
struct v4l2_m2m_ctx *ctx;
};Helpers could shorten access to the state, and drivers can sub-class struct v4l2_device_state by making it a pointer here and delegating allocation and initialization of the state to drivers.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
Quoted 8 lines
RPi CFE driver is one such case, where a single driver structure stores both metadata and video format. But if I understand correctly, it creates separate video device nodes for metadata and video capture, so it can be managed through a single v4l2_format.fmt union for each video device.
Are there any non-M2M drivers which allow more than one type of formats to be set on the same device node?
For non-m2m device I would consider the above a non-issue. As Jai said the rp1-cfe driver uses two instances of 'struct v4l2_format' to store the meta and capture formats, but they're not used at the same time. IOW the format information can be easily move to be per-video-device state.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
4) video devices can also support an OVERLAY or
OUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.Yes, bcm2835-camera should be dropped hopefully in a couple more revisions of
https://lore.kernel.org/all/[email protected]/Quoted 4 lines
Quoted 4 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.Sure, I think we can modify the existing state struct to store both capture and output formats, and keep it inside struct
v4l2_fhfor M2M devices.
I don't think we want to store multiple v4l2_formats (or members of the fmt union) in the state. You would need one for each member of the fmt union as you don't know which one the driver will use. I would keep trying to have a single v4l2_format per state and place the state in the right place so that only a single format is needed (see above for m2m).
Quoted 3 lines
This will definitely be confusing for driver developers, as currently the two example patches in this series access the state directly. So I will add
Argh, they shouldn't :)
Quoted 2 lines
framework helpers to access the correct state and format type, and document properly that it should never be accessed manually by drivers.
Thanks!
Quoted 9 lines
Quoted 6 lines
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming
video_device_statesince it isn'tvideo_devicespecific, i.e. it can either live invideo_deviceor inv4l2_fh, and in the latter case you'd have two instances: capture and output state.Argh, naming is the hardest problem :-)
Do you have any suggestions?
What do you think about the above idea of subclassing a generic v4l2_device_state with video_device_state and m2m_context_state ?
Quoted 4 lines
I personally don't think
video_device_stateis a bad name, even if it is stored somewhere else for m2m devices, given it is still the "state" of the video device, even if it is not persistent across multiple file opens.
I think the problem is mostly due to the fact a video_device_state stores a video_device * which is not relevant for m2m..
Quoted 4 lines
I was trying to avoid names with "context" in then, so it does not clash with Jacopo's work.
Thanks ;)
Quoted 67 lines
Quoted 64 lines
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir * Thanks,
Jai
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
In reply to Jai LuthraQuoted 148 lines · Jai Luthra
Hi Hans,
Thanks for the review.
Quoting Hans Verkuil (2025-09-22 13:30:05)
Quoted 131 lines · Hans Verkuil
Quoted 130 lines
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:Quoted 3 lines
Quoted 3 lines
1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.Ah I see, so for M2M devices the formats are stored per-context, where the context is tied to the filehandle. In that case, I agree that storing the format state inside struct
video_devicewould not work.Quoted 3 lines
Quoted 3 lines
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
Quoted 7 lines
RPi CFE driver is one such case, where a single driver structure stores both metadata and video format. But if I understand correctly, it creates separate video device nodes for metadata and video capture, so it can be managed through a single v4l2_format.fmt union for each video device.
Are there any non-M2M drivers which allow more than one type of formats to be set on the same device node?
I think this one does that:
drivers/media/pci/intel/ipu6/ipu6-isys-video.c
I think it can set both video and metadata formats, but it can only stream one type at a time. I'm not 100% certain of that, but that's what it looks like reading the code.
Quoted 33 lines
Quoted 6 lines
Quoted 6 lines
4) video devices can also support an OVERLAY or
OUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.Yes, bcm2835-camera should be dropped hopefully in a couple more revisions of
https://lore.kernel.org/all/[email protected]/Quoted 8 lines
Quoted 8 lines
2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.Sure, I think we can modify the existing state struct to store both capture and output formats, and keep it inside struct
v4l2_fhfor M2M devices.This will definitely be confusing for driver developers, as currently the two example patches in this series access the state directly. So I will add framework helpers to access the correct state and format type, and document properly that it should never be accessed manually by drivers.
Quoted 5 lines
Follow-up: assuming we want to support M2M devices as well (I think we should), then consider renaming
video_device_statesince it isn'tvideo_devicespecific, i.e. it can either live invideo_deviceor inv4l2_fh, and in the latter case you'd have two instances: capture and output state.
Quoted 6 lines
Argh, naming is the hardest problem :-)
Do you have any suggestions?I personally don't think
video_device_stateis a bad name, even if it is stored somewhere else for m2m devices, given it is still the "state" of the video device, even if it is not persistent across multiple file opens.
Perhaps just v4l2_state?
video_device_state refers to struct video_device, so that's not a good name.
Regards,
Hans
Quoted 71 lines
I was trying to avoid names with "context" in then, so it does not clash with Jacopo's work.
Quoted 64 lines
Regards,
Hans
Quoted 58 lines
Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir * Thanks,
Jai
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
In reply to Hans VerkuilQuoted 130 lines · Hans Verkuil
Hi Jai,
Apologies that I had no time to review v1, but I'll review v2 today.
Quoted 111 lines · Jai Luthra
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation. In the future, this may be extended or subclassed by device drivers to store their internal state variables.
Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 27 +++++++++++++++++++++++++ include/media/v4l2-dev.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +27
-0@@ -163,6 +163,27 @@ void video_device_release_empty(struct video_device *vdev) }EXPORT_SYMBOL (video_device_release_empty); +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev) +{ +struct video_device_state *state = +kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); + +if (!state) +return ERR_PTR (-ENOMEM ); + + state->vdev = vdev; + +return state; +} +EXPORT_SYMBOL_GPL (__video_device_state_alloc); + +void __video_device_state_free (struct video_device_state *state) +{ +kfree (state); +} +EXPORT_SYMBOL_GPL (__video_device_state_free); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);@@ -939,6 +960,10 @@ int __video_register_device(struct video_device *vdev,spin_lock_init (&vdev->fh_lock);INIT_LIST_HEAD (&vdev->fh_list); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) + vdev->state =__video_device_state_alloc (vdev); +/* Part 1: check device type */ switch (type) {case VFL_TYPE_VIDEO :@@ -1127,6 +1152,8 @@ void video_unregister_device(struct video_device *vdev)clear_bit (V4L2_FL_REGISTERED , &vdev->flags);mutex_unlock (&videodev_lock);v4l2_event_wake_all (vdev); +if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) +__video_device_state_free (vdev->state);device_unregister (&vdev->dev); }EXPORT_SYMBOL (video_unregister_device);include/media/v4l2-dev.h +6
-0@@ -89,12 +89,18 @@ struct dentry;* set by the core when the sub-devices device nodes are registered with * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl * handler to restrict access to some ioctl calls. +* @V4L2_FL_USES_STATE: +* indicates that the &struct video_device has state support. +* The active video and metadata formats are stored in video_device.state, +* and the try video and metadata formats are stored in v4l2_fh.state. +* All new drivers should use it. */ enum v4l2_video_device_flags {V4L2_FL_REGISTERED =0 ,V4L2_FL_USES_V4L2_FH =1 ,V4L2_FL_QUIRK_INVERTED_CROP =2 ,V4L2_FL_SUBDEV_RO_DEVNODE =3 , +V4L2_FL_USES_STATE =4 , };/* Priority helper functions */ @@ -214,6 +220,17 @@ struct v4l2_file_operations {int (*release) (struct file *);include/media/v4l2-dev.h struct v4l2_file_operations { · line 230
Quoted 10 lines
include/media/v4l2-dev.h +8
-0}; +/** +* struct video_device_state - Used for storing video device state information. +* +* @fmt: Format of the capture stream +* @vdev: Pointer to video device +*/ +struct video_device_state { +struct v4l2_format fmt;While typically a
video_devicesupports only a single video format type, that is not always the case. There are the following exceptions:
Quoted 4 lines
1) M2M devices have both a capture and output video format. However, for M2M devices the state is per-filehandle, so it shouldn't be stored in a
video_device_statestruct anyway.
2) VBI devices can have both a raw and sliced VBI format (either capture or output)
This is actually wrong. VBI devices are either in raw or in sliced VBI mode, you can't have both at the same time. So a single v4l2_format in the state is fine for this.
Regards,
Hans
Quoted 73 lines
3) AFAIK non-M2M video devices can have both a video and meta format. That may have changed, I'm not 100% certain about this.
4) video devices can also support an OVERLAY orOUTPUT_OVERLAYformat (rare)
V4L2_CAP_VIDEO_OVERLAYis currently only used indrivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c, so once that driver disappears we can drop video overlay support for capture devices.2-4 are all quite rare, but 1 is very common. But for such devices the state wouldn't be in
video_deviceanyway.But it would be nice if the same struct can be used in both m2m devices and non-m2m devices. It's just stored either in struct
v4l2_fhor structvideo_device. It would give a lot of opportunities for creating helper functions to make the life for driver developers easier.Regards,
Hans
Quoted 51 lines
include/media/v4l2-dev.h +26
-0+struct video_device *vdev; +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to @@ -238,6 +255,7 @@ struct v4l2_file_operations {* @queue: &struct vb2_queue associated with this device node. May be NULL. * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. +* @state: &struct video_device_state, holds the active state for the device. * @name: video device name * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m @@ -283,6 +301,7 @@ struct video_device {struct vb2_queue *queue;struct v4l2_prio_state *prio; +struct video_device_state *state;/* device info */ char name[64 ];@@ -546,6 +565,27 @@ static inline int video_is_registered(struct video_device *vdev)return test_bit (V4L2_FL_REGISTERED , &vdev->flags); } +/** __video_device_state_alloc - allocate video device state structure +* +* @vdev: pointer to struct video_device +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +struct video_device_state * +__video_device_state_alloc (struct video_device *vdev); + +/** __video_device_state_free - free video device state structure +* +* @state: pointer to the state to be freed +* +* .. note:: +* +* This function is meant to be used only inside the V4L2 core. +*/ +void __video_device_state_free (struct video_device_state *state); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
In reply to Jai LuthraEm Fri, 19 Sep 2025 15:25:53 +0530
Jai Luthra <[email protected]> escreveu:
Quoted 4 lines
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation.
I didn't look at the patch series yet, so I may be just jumping too fast here, but storing "try" attempts doesn't seem the right thing to do.
Btw, IMHO, the first patch on this series should be against documentation, where you would be describing not only the new feature with the supported states, but also the state machine transitions that are supported, preferably with some graphs.
So, before actually looking on any code changes, I'd like to see a clear description of this new feature, what it is proposing to address, how and what impacts (if any) this would bring to userspace.
The current diffstat:
include/media/v4l2-ctrls.h | 5 +- include/media/v4l2-dev.h | 84 +++++ include/media/v4l2-fh.h | 2 + include/media/v4l2-ioctl.h | 238 ++++++------- include/media/v4l2-mem2mem.h | 48 ++- include/media/videobuf2-v4l2.h | 33 +-
implies that this affects for now only Documentation/driver-api/media/...
Quoted 9 lines
In the
future, this may be extended or subclassed by device drivers to store their internal state variables.Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.
Quoted 5 lines
This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
... but when you mention "contexts", I'm assuming that you're aiming at either userspace API changes and/or behavoral changes that will affect uAPI as well.
Thanks,
Mauro
Re: [PATCH v2 01/10] media: v4l2-core: Introduce state management for video devices
Hi Mauro,
Quoting Mauro Carvalho Chehab (2025-09-24 15:45:45)
Quoted 23 lines
Em Fri, 19 Sep 2025 15:25:53 +0530
Jai Luthra <[email protected]> escreveu:Quoted 4 lines
Similar to V4L2 subdev states, introduce state support for video devices to provide a centralized location for storing device state information. This includes the current (active) pixelformat used by the device and the temporary (try) pixelformat used during format negotiation.
I didn't look at the patch series yet, so I may be just jumping too fast here, but storing "try" attempts doesn't seem the right thing to do.
Btw, IMHO, the first patch on this series should be against documentation, where you would be describing not only the new feature with the supported states, but also the state machine transitions that are supported, preferably with some graphs.
So, before actually looking on any code changes, I'd like to see a clear description of this new feature, what it is proposing to address, how and what impacts (if any) this would bring to userspace.
The current diffstat:
Quoted 8 lines
include/media/v4l2-ctrls.h | 5 +- include/media/v4l2-dev.h | 84 +++++ include/media/v4l2-fh.h | 2 + include/media/v4l2-ioctl.h | 238 ++++++------- include/media/v4l2-mem2mem.h | 48 ++- include/media/videobuf2-v4l2.h | 33 +-implies that this affects for now only
Documentation/driver-api/media/...
There shouldn't be any change to userspace with this series. The state structure introduced here is only for internal use by the drivers, which currently store the applied formats in driver-specific structures.
In the next revision, I will add documentation in v4l2-dev.rst similar to how the subdev state is described in v4l2-subdev.rst.
Quoted 16 lines
Quoted 10 lines
In the
future, this may be extended or subclassed by device drivers to store their internal state variables.Also introduce a flag for drivers that wish to use this state management. When set, the framework automatically allocates the state during device registration and stores a pointer to it within the
video_devicestructure.Quoted 5 lines
This change aligns video devices with V4L2 subdevices by storing hardware state in a common framework-allocated structure. This is the first step towards enabling the multiplexing of the underlying hardware by using different software "contexts", each represented by the combined state of all video devices and V4L2 subdevices in a complex media graph.
Quoted 3 lines
... but when you mention "contexts", I'm assuming that you're aiming at either userspace API changes and/or behavoral changes that will affect uAPI as well.
Yes, the userspace side changes are documented in Jacopo's series adding context support for media devices, for example:
Quoted 3 lines
Thanks,
Mauro
Thanks,
Jai
PATCH v2 2/10 media: v4l2-dev: Add support for try state
In reply to Jai LuthraFormat negotiation performed via the TRY_FMT ioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.
Introduce an enum to distinguish between these two state types and store the try state in struct v4l2_fh instead of the video device structure. The try state is allocated during file handle initialization in v4l2_fh_init() and released in v4l2_fh_exit().
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-dev.c | 7 +++++-- drivers/media/v4l2-core/v4l2-fh.c | 6 ++++++ include/media/v4l2-dev.h | 17 ++++++++++++++++- include/media/v4l2-fh.h | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +5 -2
@@ -164,7 +164,8 @@ void video_device_release_empty(struct video_device *vdev)EXPORT_SYMBOL (video_device_release_empty);struct video_device_state * -__video_device_state_alloc (struct video_device *vdev) +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which) {struct video_device_state *state =kzalloc (sizeof (struct video_device_state ),GFP_KERNEL );
@@ -172,6 +173,7 @@ __video_device_state_alloc(struct video_device *vdev)if (!state)return ERR_PTR (-ENOMEM ); + state->which = which; state->vdev = vdev;return state;
@@ -962,7 +964,8 @@ int __video_register_device(struct video_device *vdev,/* state support */ if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) - vdev->state =__video_device_state_alloc (vdev); + vdev->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_ACTIVE );/* Part 1: check device type */ switch (type) {
drivers/media/v4l2-core/v4l2-fh.c +6 -0
@@ -38,6 +38,10 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)INIT_LIST_HEAD (&fh->subscribed); fh->sequence =-1 ;mutex_init (&fh->subscribe_lock); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) + fh->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_TRY ); }EXPORT_SYMBOL_GPL (v4l2_fh_init);
@@ -84,6 +88,8 @@ void v4l2_fh_exit(struct v4l2_fh *fh) {if (fh->vdev ==NULL )return ; +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) +kfree (fh->state);v4l_disable_media_source (fh->vdev);v4l2_event_unsubscribe_all (fh);mutex_destroy (&fh->subscribe_lock);
include/media/v4l2-dev.h +16 -1
@@ -220,15 +220,28 @@ struct v4l2_file_operations {int (*release) (struct file *); }; +/** +* enum video_device_state_whence - Video device state type +* +* @VIDEO_DEVICE_STATE_TRY: from VIDIOC_TRY_xxx, for negotiation only +* @VIDEO_DEVICE_STATE_ACTIVE: from VIDIOC_S_xxx, applied to the device +*/ +enum video_device_state_whence { +VIDEO_DEVICE_STATE_TRY =0 , +VIDEO_DEVICE_STATE_ACTIVE =1 , +}; +/** * struct video_device_state - Used for storing video device state information. * * @fmt: Format of the capture stream * @vdev: Pointer to video device +* @which: State type (from enum video_device_state_whence) */ struct video_device_state {struct v4l2_format fmt;struct video_device *vdev; +enum video_device_state_whence which; };/*
@@ -568,13 +581,15 @@ static inline int video_is_registered(struct video_device *vdev)/** __video_device_state_alloc - allocate video device state structure * * @vdev: pointer to struct video_device +* @which: type of video device state (from enum video_device_state_whence) * * .. note:: * * This function is meant to be used only inside the V4L2 core. */ struct video_device_state * -__video_device_state_alloc (struct video_device *vdev); +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which);/** __video_device_state_free - free video device state structure *
include/media/v4l2-fh.h +2 -0
@@ -28,6 +28,7 @@ struct v4l2_ctrl_handler;* @vdev: pointer to &struct video_device * @ctrl_handler: pointer to &struct v4l2_ctrl_handler * @prio: priority of the file handler, as defined by &enum v4l2_priority +* @state: try state used for format negotiation on the video device * * @wait: event' s wait queue * @subscribe_lock: serialise changes to the subscribed list; guarantee that
@@ -44,6 +45,7 @@ struct v4l2_fh {struct video_device *vdev;struct v4l2_ctrl_handler *ctrl_handler;enum v4l2_priority prio; +struct video_device_state *state;/* Events */ wait_queue_head_t wait;
Signature · 1 line
2.51.0
Re: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Quoted 9 lines · Jai Luthra
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().
There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Regards,
Hans
Quoted 146 lines
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 7 +++++-- drivers/media/v4l2-core/v4l2-fh.c | 6 ++++++ include/media/v4l2-dev.h | 17 ++++++++++++++++- include/media/v4l2-fh.h | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-)drivers/media/v4l2-core/v4l2-dev.c +5
-2@@ -164,7 +164,8 @@ void video_device_release_empty(struct video_device *vdev)EXPORT_SYMBOL (video_device_release_empty);struct video_device_state * -__video_device_state_alloc (struct video_device *vdev) +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which) {struct video_device_state *state =kzalloc (sizeof (struct video_device_state ),GFP_KERNEL );@@ -172,6 +173,7 @@ __video_device_state_alloc(struct video_device *vdev)if (!state)return ERR_PTR (-ENOMEM ); + state->which = which; state->vdev = vdev;return state;@@ -962,7 +964,8 @@ int __video_register_device(struct video_device *vdev,/* state support */ if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) - vdev->state =__video_device_state_alloc (vdev); + vdev->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_ACTIVE );/* Part 1: check device type */ switch (type) {drivers/media/v4l2-core/v4l2-fh.c +6
-0@@ -38,6 +38,10 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)INIT_LIST_HEAD (&fh->subscribed); fh->sequence =-1 ;mutex_init (&fh->subscribe_lock); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) + fh->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_TRY ); }EXPORT_SYMBOL_GPL (v4l2_fh_init);@@ -84,6 +88,8 @@ void v4l2_fh_exit(struct v4l2_fh *fh) {if (fh->vdev ==NULL )return ; +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) +kfree (fh->state);v4l_disable_media_source (fh->vdev);v4l2_event_unsubscribe_all (fh);mutex_destroy (&fh->subscribe_lock);include/media/v4l2-dev.h +16
-1@@ -220,15 +220,28 @@ struct v4l2_file_operations {int (*release) (struct file *); }; +/** +* enum video_device_state_whence - Video device state type +* +* @VIDEO_DEVICE_STATE_TRY: from VIDIOC_TRY_xxx, for negotiation only +* @VIDEO_DEVICE_STATE_ACTIVE: from VIDIOC_S_xxx, applied to the device +*/ +enum video_device_state_whence { +VIDEO_DEVICE_STATE_TRY =0 , +VIDEO_DEVICE_STATE_ACTIVE =1 , +}; +/** * struct video_device_state - Used for storing video device state information. * * @fmt: Format of the capture stream * @vdev: Pointer to video device +* @which: State type (from enum video_device_state_whence) */ struct video_device_state {struct v4l2_format fmt;struct video_device *vdev; +enum video_device_state_whence which; };/* @@ -568,13 +581,15 @@ static inline int video_is_registered(struct video_device *vdev)/** __video_device_state_alloc - allocate video device state structure * * @vdev: pointer to struct video_device +* @which: type of video device state (from enum video_device_state_whence) * * .. note:: * * This function is meant to be used only inside the V4L2 core. */ struct video_device_state * -__video_device_state_alloc (struct video_device *vdev); +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which);/** __video_device_state_free - free video device state structure * include/media/v4l2-fh.h +2
-0@@ -28,6 +28,7 @@ struct v4l2_ctrl_handler;* @vdev: pointer to &struct video_device * @ctrl_handler: pointer to &struct v4l2_ctrl_handler * @prio: priority of the file handler, as defined by &enum v4l2_priority +* @state: try state used for format negotiation on the video device * * @wait: event' s wait queue * @subscribe_lock: serialise changes to the subscribed list; guarantee that @@ -44,6 +45,7 @@ struct v4l2_fh {struct video_device *vdev;struct v4l2_ctrl_handler *ctrl_handler;enum v4l2_priority prio; +struct video_device_state *state;/* Events */ wait_queue_head_t wait;
Re: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Quoted 15 lines · Hans Verkuil
Quoted 9 lines · Jai Luthra
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.
Quoted 5 lines
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Follow-up: if there are no plans to change/enhance the VIDIOC_TRY_FMT semantics, then I don't really see the point of this since there is no need to store this information.
Regards,
Hans
Quoted 153 lines
Regards,
Hans
Quoted 146 lines
Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 7 +++++-- drivers/media/v4l2-core/v4l2-fh.c | 6 ++++++ include/media/v4l2-dev.h | 17 ++++++++++++++++- include/media/v4l2-fh.h | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-)drivers/media/v4l2-core/v4l2-dev.c +5
-2@@ -164,7 +164,8 @@ void video_device_release_empty(struct video_device *vdev)EXPORT_SYMBOL (video_device_release_empty);struct video_device_state * -__video_device_state_alloc (struct video_device *vdev) +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which) {struct video_device_state *state =kzalloc (sizeof (struct video_device_state ),GFP_KERNEL );@@ -172,6 +173,7 @@ __video_device_state_alloc(struct video_device *vdev)if (!state)return ERR_PTR (-ENOMEM ); + state->which = which; state->vdev = vdev;return state;@@ -962,7 +964,8 @@ int __video_register_device(struct video_device *vdev,/* state support */ if (test_bit (V4L2_FL_USES_STATE , &vdev->flags)) - vdev->state =__video_device_state_alloc (vdev); + vdev->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_ACTIVE );/* Part 1: check device type */ switch (type) {drivers/media/v4l2-core/v4l2-fh.c +6
-0@@ -38,6 +38,10 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)INIT_LIST_HEAD (&fh->subscribed); fh->sequence =-1 ;mutex_init (&fh->subscribe_lock); +/* state support */ +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) + fh->state =__video_device_state_alloc (vdev, +VIDEO_DEVICE_STATE_TRY ); }EXPORT_SYMBOL_GPL (v4l2_fh_init);@@ -84,6 +88,8 @@ void v4l2_fh_exit(struct v4l2_fh *fh) {if (fh->vdev ==NULL )return ; +if (test_bit (V4L2_FL_USES_STATE , &fh->vdev->flags)) +kfree (fh->state);v4l_disable_media_source (fh->vdev);v4l2_event_unsubscribe_all (fh);mutex_destroy (&fh->subscribe_lock);include/media/v4l2-dev.h +16
-1@@ -220,15 +220,28 @@ struct v4l2_file_operations {int (*release) (struct file *); }; +/** +* enum video_device_state_whence - Video device state type +* +* @VIDEO_DEVICE_STATE_TRY: from VIDIOC_TRY_xxx, for negotiation only +* @VIDEO_DEVICE_STATE_ACTIVE: from VIDIOC_S_xxx, applied to the device +*/ +enum video_device_state_whence { +VIDEO_DEVICE_STATE_TRY =0 , +VIDEO_DEVICE_STATE_ACTIVE =1 , +}; +/** * struct video_device_state - Used for storing video device state information. * * @fmt: Format of the capture stream * @vdev: Pointer to video device +* @which: State type (from enum video_device_state_whence) */ struct video_device_state {struct v4l2_format fmt;struct video_device *vdev; +enum video_device_state_whence which; };/* @@ -568,13 +581,15 @@ static inline int video_is_registered(struct video_device *vdev)/** __video_device_state_alloc - allocate video device state structure * * @vdev: pointer to struct video_device +* @which: type of video device state (from enum video_device_state_whence) * * .. note:: * * This function is meant to be used only inside the V4L2 core. */ struct video_device_state * -__video_device_state_alloc (struct video_device *vdev); +__video_device_state_alloc (struct video_device *vdev, +enum video_device_state_whence which);/** __video_device_state_free - free video device state structure * include/media/v4l2-fh.h +2
-0@@ -28,6 +28,7 @@ struct v4l2_ctrl_handler;* @vdev: pointer to &struct video_device * @ctrl_handler: pointer to &struct v4l2_ctrl_handler * @prio: priority of the file handler, as defined by &enum v4l2_priority +* @state: try state used for format negotiation on the video device * * @wait: event' s wait queue * @subscribe_lock: serialise changes to the subscribed list; guarantee that @@ -44,6 +45,7 @@ struct v4l2_fh {struct video_device *vdev;struct v4l2_ctrl_handler *ctrl_handler;enum v4l2_priority prio; +struct video_device_state *state;/* Events */ wait_queue_head_t wait;
Re: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Hi Hans,
Quoting Hans Verkuil (2025-09-22 13:28:26)
Quoted 12 lines · Hans Verkuil
Quoted 11 lines · Jai Luthra
Quoted 9 lines
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().
Quoted 4 lines
Quoted 4 lines
There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.
Yes, the v4l2 format sent with VIDIOC_TRY_FMT is currently not stored by the drivers, but simply modified and returned back to userspace. From the userspace point of view, that should still work the same way with this series.
The drivers will get access to the correct state (active) for internal use through framework helpers (that will be introduced in next revision), so the try state doesn't have any real "use" today.
Quoted 9 lines
Quoted 5 lines
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Follow-up: if there are no plans to change/enhance the
VIDIOC_TRY_FMTsemantics, then I don't really see the point of this since there is no need to store this information.
There are no plans to change the userspace side of this. The main motivation to allocate and keep a try state in the framework is to simplify the driver implementation. A single function can serve as both s_fmt and try_fmt ioctl handler, and operate on the passed state argument without caring if it will be applied on the device or just for negotiation.
In future, drivers may subclass the state with their device specific data, so that nothing tied to the hardware state is stored in the driver structures directly, but I don't see why drivers will need to inspect TRY formats.
Quoted 10 lines
Regards,
Hans
Quoted 5 lines
Regards,
Hans
Thanks,
Jai
[snip]
Re: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Quoted 45 lines · Jai Luthra
Hi Hans,
Quoting Hans Verkuil (2025-09-22 13:28:26)
Quoted 12 lines · Hans Verkuil
Quoted 11 lines · Jai Luthra
Quoted 9 lines
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().Quoted 4 lines
Quoted 4 lines
There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.Yes, the v4l2 format sent with
VIDIOC_TRY_FMTis currently not stored by the drivers, but simply modified and returned back to userspace. From the userspace point of view, that should still work the same way with this series.The drivers will get access to the correct state (active) for internal use through framework helpers (that will be introduced in next revision), so the try state doesn't have any real "use" today.
Quoted 9 lines
Quoted 5 lines
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Follow-up: if there are no plans to change/enhance the
VIDIOC_TRY_FMTsemantics, then I don't really see the point of this since there is no need to store this information.There are no plans to change the userspace side of this. The main motivation to allocate and keep a try state in the framework is to simplify the driver implementation. A single function can serve as both
s_fmtandtry_fmtioctl handler, and operate on the passed state argument without caring if it will be applied on the device or just for negotiation.
Quoted 4 lines
In future, drivers may subclass the state with their device specific data, so that nothing tied to the hardware state is stored in the driver structures directly, but I don't see why drivers will need to inspect TRY formats.
I think having an unused try state is a bad idea and really confusing.
Especially because for subdevices the try state is actually used, so for normal devices you would automatically expect the same thing when you see a try state.
You should reconsider this approach.
Regards,
Hans
Jacopo Mondi
maintainerRe: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Hi Hans
Quoted 46 lines · Hans Verkuil
Quoted 45 lines · Jai Luthra
Hi Hans,
Quoting Hans Verkuil (2025-09-22 13:28:26)
Quoted 12 lines · Hans Verkuil
Quoted 11 lines · Jai Luthra
Quoted 9 lines
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().Quoted 4 lines
Quoted 4 lines
There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.Yes, the v4l2 format sent with
VIDIOC_TRY_FMTis currently not stored by the drivers, but simply modified and returned back to userspace. From the userspace point of view, that should still work the same way with this series.The drivers will get access to the correct state (active) for internal use through framework helpers (that will be introduced in next revision), so the try state doesn't have any real "use" today.
Quoted 9 lines
Quoted 5 lines
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Follow-up: if there are no plans to change/enhance the
VIDIOC_TRY_FMTsemantics, then I don't really see the point of this since there is no need to store this information.There are no plans to change the userspace side of this. The main motivation to allocate and keep a try state in the framework is to simplify the driver implementation. A single function can serve as both
s_fmtandtry_fmtioctl handler, and operate on the passed state argument without caring if it will be applied on the device or just for negotiation.
Quoted 8 lines
Quoted 4 lines
In future, drivers may subclass the state with their device specific data, so that nothing tied to the hardware state is stored in the driver structures directly, but I don't see why drivers will need to inspect TRY formats.
I think having an unused try state is a bad idea and really confusing.
Especially because for subdevices the try state is actually used, so
I might have missed where. TRY formats on subdev sink pads influence TRY formats on the source pads, are there other usages I might be overlooking ?
Quoted 4 lines
for normal devices you would automatically expect the same thing when you see a try state.
You should reconsider this approach.
The 'try' state will be stored in the v4l2_fh and won't be accessible to userspace.
Drivers instead, might accumulate the result of multiple TRY_FMT calls into the state stored in the v4l2_fh incrementally. Is this a concern for you ?
I still think having a single implementation for s_fmt and try_fmt is a win for drivers, even if the try state are now effectively stored somewhere.
Thanks
j
Quoted 4 lines
Regards,
Hans
Re: [PATCH v2 02/10] media: v4l2-dev: Add support for try state
Quoted 54 lines · Jacopo Mondi
Hi Hans
Quoted 51 lines · Hans Verkuil
Quoted 49 lines · Jai Luthra
Hi Hans,
Quoting Hans Verkuil (2025-09-22 13:28:26)
Quoted 12 lines · Hans Verkuil
Quoted 11 lines · Jai Luthra
Quoted 9 lines
Format negotiation performed via the
TRY_FMTioctl should only affect the temporary context of a specific filehandle, not the active state stored in the video device structure. To support this distinction, we need separate storage for try and active states.Introduce an enum to distinguish between these two state types and store the try state in struct
v4l2_fhinstead of the video device structure. The try state is allocated during file handle initialization inv4l2_fh_init()and released inv4l2_fh_exit().Quoted 4 lines
Quoted 4 lines
There is a major difference between TRY in video devices and TRY in subdev
devices: TRY for video devices is not persistent, i.e. it doesn't need to be stored anywhere since nobody will be using that information.Yes, the v4l2 format sent with
VIDIOC_TRY_FMTis currently not stored by the drivers, but simply modified and returned back to userspace. From the userspace point of view, that should still work the same way with this series.The drivers will get access to the correct state (active) for internal use through framework helpers (that will be introduced in next revision), so the try state doesn't have any real "use" today.
Quoted 9 lines
Quoted 5 lines
If the plan is to change that in later patch series, then that should be very clearly stated. And I think I would need to know the details of those future plans before I can OK this.
So how is this try state intended to be used in the future?
Follow-up: if there are no plans to change/enhance the
VIDIOC_TRY_FMTsemantics, then I don't really see the point of this since there is no need to store this information.There are no plans to change the userspace side of this. The main motivation to allocate and keep a try state in the framework is to simplify the driver implementation. A single function can serve as both
s_fmtandtry_fmtioctl handler, and operate on the passed state argument without caring if it will be applied on the device or just for negotiation.In future, drivers may subclass the state with their device specific data, so that nothing tied to the hardware state is stored in the driver structures directly, but I don't see why drivers will need to inspect TRY formats.
Quoted 7 lines
Quoted 3 lines
I think having an unused try state is a bad idea and really confusing.
Especially because for subdevices the try state is actually used, so
I might have missed where. TRY formats on subdev sink pads influence TRY formats on the source pads, are there other usages I might be overlooking ?
That's the main one. But also that the TRY format for a subdev filehandle is persistent, i.e. you can query it later.
For video devices this is not stored, i.e. there is no G_TRY_FMT equivalent. TRY_FMT takes the format, it validates it and returns it, but it is not stored anywhere.
Quoted 11 lines
Quoted 4 lines
for normal devices you would automatically expect the same thing when you see a try state.
You should reconsider this approach.
The 'try' state will be stored in the
v4l2_fhand won't be accessible to userspace.Drivers instead, might accumulate the result of multiple
TRY_FMTcalls into the state stored in thev4l2_fhincrementally. Is this a concern for you ?
Basically the try state would be a scratch state, it's not used for anything else. I think it is very confusing keeping it.
Quoted 4 lines
I still think having a single implementation for
s_fmtandtry_fmtis a win for drivers, even if the try state are now effectively stored somewhere.
In a properly written driver s_fmt will call try_fmt first to validate the given format, then use that format to actually program the hardware.
Unfortunately, a lot of drivers have duplicate format validation code for both try_fmt and s_fmt (hopefully, but not always, doing the same validation).
I think this is partially historic. When the vidioc_g/s/try_vid_cap etc. ops were introduced, drivers had to be converted as well. And if memory serves often drivers handled TRY and S_FMT in a single function, and that now had to be split up, so I suspect that in quite a few cases the code was simply duplicated.
It's a long time ago though, so I may be wrong about that.
Also, older drivers do not always support TRY_FMT. Although I'm not sure how many of such drivers remain.
Regards,
Hans
Quoted 8 lines
Thanks
jQuoted 4 lines
Regards,
Hans
PATCH v2 3/10 media: v4l2-dev: Add callback for initializing video device state
In reply to Jai LuthraDrivers may need to initialize the video device state with default values, such as setting a default pixelformat and resolution.
Introduce an optional callback that drivers can populate. The framework calls this callback during state allocation to allow driver-specific initialization.
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-dev.c | 13 +++++++++++++ include/media/v4l2-dev.h | 11 +++++++++++ 2 files changed, 24 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +13 -0
@@ -169,6 +169,7 @@ __video_device_state_alloc(struct video_device *vdev, {struct video_device_state *state =kzalloc (sizeof (struct video_device_state ),GFP_KERNEL ); +int ret;if (!state)return ERR_PTR (-ENOMEM );
@@ -176,7 +177,19 @@ __video_device_state_alloc(struct video_device *vdev, state->which = which; state->vdev = vdev; +if (vdev->vdev_ops && vdev->vdev_ops->init_state) { + ret = vdev->vdev_ops->init_state (state); + +if (ret) + goto err; + } +return state; + +err: +kfree (state); + +return ERR_PTR (ret); }EXPORT_SYMBOL_GPL (__video_device_state_alloc);
include/media/v4l2-dev.h +11 -0
@@ -244,6 +244,15 @@ struct video_device_state {enum video_device_state_whence which; }; +/** +* struct video_device_internal_ops - Callbacks for video device management. +* +* @init_state: pointer to a function that initializes the video device state. +*/ +struct video_device_internal_ops { +int (*init_state)(struct video_device_state *state); +}; +/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to
@@ -284,6 +293,7 @@ struct video_device_state {* * @release: video device release() callback * @ioctl_ops: pointer to &struct v4l2_ioctl_ops with ioctl callbacks +* @vdev_ops: pointer to &struct video_device_internal_ops * * @valid_ioctls: bitmap with the valid ioctls for this device * @lock: pointer to &struct mutex serialization lock
@@ -336,6 +346,7 @@ struct video_device {/* callbacks */ void (*release)(struct video_device *vdev);const struct v4l2_ioctl_ops *ioctl_ops; +const struct video_device_internal_ops *vdev_ops;DECLARE_BITMAP (valid_ioctls,BASE_VIDIOC_PRIVATE );struct mutex *lock;
Signature · 1 line
2.51.0
PATCH v2 4/10 media: v4l2-dev: Add helpers to get current format from the state
In reply to Jai LuthraAdd a helper function that drivers can call to retrieve the current v4l2_format stored in a video device state for internal use.
Additionally, provide a G_FMT ioctl implementation that drivers can use instead of writing their own when the format is stored in the active state.
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-dev.c | 23 +++++++++++++++++++++++ include/media/v4l2-dev.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +23 -0
@@ -199,6 +199,29 @@ void __video_device_state_free(struct video_device_state *state) }EXPORT_SYMBOL_GPL (__video_device_state_free); +struct v4l2_format *video_device_state_get_fmt (struct video_device_state *state) +{ +if (WARN_ON_ONCE (!state)) +return NULL ; + +return &state->fmt; +} +EXPORT_SYMBOL_GPL (video_device_state_get_fmt); + +int video_device_g_fmt (struct file *file,void *priv,struct v4l2_format *fmt) +{ +struct video_device_state *state = priv; +struct v4l2_format *vfmt =video_device_state_get_fmt (state); + +if (!vfmt) +return -EINVAL ; + + *fmt = *vfmt; + +return 0 ; +} +EXPORT_SYMBOL_GPL (video_device_g_fmt); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);
include/media/v4l2-dev.h +18 -0
@@ -612,6 +612,24 @@ __video_device_state_alloc(struct video_device *vdev,*/ void __video_device_state_free (struct video_device_state *state); +/** +* video_device_state_get_fmt - get current v4l2_format. +* +* @state: pointer to struct video_device_state +*/ +struct v4l2_format * +video_device_state_get_fmt (struct video_device_state *state); + +/** +* video_device_g_fmt - fill v4l2_format from the state. +* +* @file: pointer to struct file +* @state: pointer to struct video_device_state +* @format: pointer to struct v4l2_format +*/ +int video_device_g_fmt (struct file *file,void *priv, +struct v4l2_format *format); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Signature · 1 line
2.51.0
Re: [PATCH v2 04/10] media: v4l2-dev: Add helpers to get current format from the state
Quoted 33 lines · Jai Luthra
Add a helper function that drivers can call to retrieve the current
v4l2_formatstored in a video device state for internal use.Additionally, provide a
G_FMTioctl implementation that drivers can use instead of writing their own when the format is stored in the active state.Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 23 +++++++++++++++++++++++ include/media/v4l2-dev.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +3
-0@@ -199,6 +199,29 @@ void __video_device_state_free(struct video_device_state *state) }EXPORT_SYMBOL_GPL (__video_device_state_free); +struct v4l2_format *video_device_state_get_fmt (struct video_device_state *state) +{ +if (WARN_ON_ONCE (!state))
drivers/media/v4l2-core/v4l2-dev.c void __video_device_state_free(struct video_device_state *state) · line 214
Quoted 10 lines
drivers/media/v4l2-core/v4l2-dev.c +10
-0+return NULL ; + +return &state->fmt; +} +EXPORT_SYMBOL_GPL (video_device_state_get_fmt); + +int video_device_g_fmt (struct file *file,void *priv,struct v4l2_format *fmt) +{ +struct video_device_state *state = priv; +struct v4l2_format *vfmt =video_device_state_get_fmt (state);
Obviously, if multiple format types are stored in state (e.g. video capture and output), then this code needs to pick the right format based on fmt->type.
I would also suggest moving this to v4l2-common.c and renaming it to v4l2_g_fmt, consistent with other helpers there (v4l2_g/s_parm_cap).
Regards,
Hans
Quoted 43 lines
drivers/media/v4l2-core/v4l2-dev.c +10
-0+ +if (!vfmt) +return -EINVAL ; + + *fmt = *vfmt; + +return 0 ; +} +EXPORT_SYMBOL_GPL (video_device_g_fmt); +static inline void video_get (struct video_device *vdev) {get_device (&vdev->dev);include/media/v4l2-dev.h +18
-0@@ -612,6 +612,24 @@ __video_device_state_alloc(struct video_device *vdev,*/ void __video_device_state_free (struct video_device_state *state); +/** +* video_device_state_get_fmt - get current v4l2_format. +* +* @state: pointer to struct video_device_state +*/ +struct v4l2_format * +video_device_state_get_fmt (struct video_device_state *state); + +/** +* video_device_g_fmt - fill v4l2_format from the state. +* +* @file: pointer to struct file +* @state: pointer to struct video_device_state +* @format: pointer to struct v4l2_format +*/ +int video_device_g_fmt (struct file *file,void *priv, +struct v4l2_format *format); +/** * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir *
Re: [PATCH v2 04/10] media: v4l2-dev: Add helpers to get current format from the state
Quoting Hans Verkuil (2025-09-22 13:36:59)
Quoted 48 lines · Jai Luthra
Quoted 33 lines
Add a helper function that drivers can call to retrieve the current
v4l2_formatstored in a video device state for internal use.Additionally, provide a
G_FMTioctl implementation that drivers can use instead of writing their own when the format is stored in the active state.Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-dev.c | 23 +++++++++++++++++++++++ include/media/v4l2-dev.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+)drivers/media/v4l2-core/v4l2-dev.c +3
-0@@ -199,6 +199,29 @@ void __video_device_state_free(struct video_device_state *state) }EXPORT_SYMBOL_GPL (__video_device_state_free); +struct v4l2_format *video_device_state_get_fmt (struct video_device_state *state) +{ +if (WARN_ON_ONCE (!state))drivers/media/v4l2-core/v4l2-dev.c void __video_device_state_free(struct video_device_state *state) · line 214
Quoted 10 lines
drivers/media/v4l2-core/v4l2-dev.c +10
-0+return NULL ; + +return &state->fmt; +} +EXPORT_SYMBOL_GPL (video_device_state_get_fmt); + +int video_device_g_fmt (struct file *file,void *priv,struct v4l2_format *fmt) +{ +struct video_device_state *state = priv; +struct v4l2_format *vfmt =video_device_state_get_fmt (state);Obviously, if multiple format types are stored in state (e.g. video capture and output), then this code needs to pick the right format based on
fmt->type.
Quoted 2 lines
I would also suggest moving this to
v4l2-common.cand renaming it tov4l2_g_fmt, consistent with other helpers there (v4l2_g/s_parm_cap).
Good catch, will fix in next revision.
Quoted 5 lines
Regards,
Hans
Quoted 10 lines
drivers/media/v4l2-core/v4l2-dev.c void __video_device_state_free(struct video_device_state *state) · line 224
Quoted 10 lines
drivers/media/v4l2-core/v4l2-dev.c +10
-0+ +if (!vfmt) +return -EINVAL ; + + *fmt = *vfmt; + +return 0 ; +} +EXPORT_SYMBOL_GPL (video_device_g_fmt); +
Thanks,
Jai
[snip]
PATCH v2 5/10 media: v4l2-ioctl: Add video_device_state argument to v4l2 ioctl wrappers
In reply to Jai LuthraAdd a third argument to all v4l2 ioctl wrappers to pass struct video_device_state * directly, replacing the previous opaque pointer approach.
Currently, this argument is populated with NULL since existing driver hooks still expect a void *priv argument. This will be addressed in a subsequent patch.
Most changes to the ioctl wrappers were generated using the following Coccinelle semantic patch:
@ioctl@
identifier v4l2_ioctls;
identifier ioctl;
identifier fn;
identifier debug;
expression flags;
@@
struct v4l2_ioctl_info v4l2_ioctls[] = {
...,
IOCTL_INFO(ioctl, fn, debug, flags),
...,
};@depends on ioctl@
identifier ioctl.fn;
identifier ops;
identifier file;
identifier arg;
identifier handler;
expression list args;
@@
-int fn(const struct v4l2_ioctl_ops *ops, struct file *file, void *arg) +int fn(const struct v4l2_ioctl_ops *ops, struct file *file,
+ struct video_device_state *state, void *arg)
{
<...
- ops->handler(file, NULL, args)
+ ops->handler(file, state, args)
...>
}Manual changes were made to handle calls to v4l_[gs]_selection, update the v4l2_ioctl_info structure definition and macros, fix argument wrapping in some function definitions, and handle the common function pointer in v4l2_ioctl_info.
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-ioctl.c | 360 ++++++++++++++++++----------------- 1 file changed, 186 insertions(+), 174 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +186 -174
@@ -1090,7 +1090,7 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) }static int v4l_querycap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_capability *cap = (struct v4l2_capability *)arg;struct video_device *vfd =video_devdata (file);
@@ -1103,7 +1103,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file,media_set_bus_info (cap->bus_info,sizeof (cap->bus_info), vfd->dev_parent); - ret = ops->vidioc_querycap (file,NULL , cap); + ret = ops->vidioc_querycap (file, state, cap);/* * Drivers must not change device_caps, so check for this and
@@ -1124,7 +1124,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_g_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);
@@ -1133,11 +1133,11 @@ static int v4l_g_input(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_input (file,NULL , arg); +return ops->vidioc_g_input (file, state, arg); }static int v4l_g_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);
@@ -1146,11 +1146,11 @@ static int v4l_g_output(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_output (file,NULL , arg); +return ops->vidioc_g_output (file, state, arg); }static int v4l_s_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;
@@ -1162,22 +1162,22 @@ static int v4l_s_input(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_input (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_input (file, state, *(unsigned int *)arg); }static int v4l_s_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_output (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_output (file, state, *(unsigned int *)arg); }static int v4l_g_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;u32 *p = arg;
@@ -1188,7 +1188,7 @@ static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;struct v4l2_fh *vfh;
@@ -1200,7 +1200,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_enuminput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_input *p = arg;
@@ -1222,11 +1222,11 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_input (file,NULL , p); +return ops->vidioc_enum_input (file, state, p); }static int v4l_enumoutput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_output *p = arg;
@@ -1248,7 +1248,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_output (file,NULL , p); +return ops->vidioc_enum_output (file, state, p); }static void v4l_fill_fmtdesc (struct v4l2_fmtdesc *fmt)
@@ -1588,7 +1588,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) }static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;
@@ -1618,12 +1618,12 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_cap))break ; - ret = ops->vidioc_enum_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_cap (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_enum_fmt_vid_overlay))break ; - ret = ops->vidioc_enum_fmt_vid_overlay (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_overlay (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE :
@@ -1635,27 +1635,27 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_out))break ; - ret = ops->vidioc_enum_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_out (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_sdr_cap))break ; - ret = ops->vidioc_enum_fmt_sdr_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_cap (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_sdr_out))break ; - ret = ops->vidioc_enum_fmt_sdr_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_out (file, state, arg);break ;case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_meta_cap))break ; - ret = ops->vidioc_enum_fmt_meta_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_cap (file, state, arg);break ;case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_meta_out))break ; - ret = ops->vidioc_enum_fmt_meta_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_out (file, state, arg);break ; }if (ret ==0 )
@@ -1679,7 +1679,7 @@ static void v4l_pix_format_touch(struct v4l2_pix_format *p) }static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);
@@ -1695,50 +1695,50 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_g_fmt_vid_cap))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )v4l_pix_format_touch (&p->fmt.pix);return ret;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -return ops->vidioc_g_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY : -return ops->vidioc_g_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE : -return ops->vidioc_g_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : -return ops->vidioc_g_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_g_fmt_vid_out))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -return ops->vidioc_g_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY : -return ops->vidioc_g_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT : -return ops->vidioc_g_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : -return ops->vidioc_g_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE : -return ops->vidioc_g_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT : -return ops->vidioc_g_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE : -return ops->vidioc_g_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_g_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT : -return ops->vidioc_g_fmt_meta_out (file,NULL , arg); +return ops->vidioc_g_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_s_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);
@@ -1758,7 +1758,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_s_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )
@@ -1771,7 +1771,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_overlay))break ;
@@ -1779,22 +1779,22 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;
@@ -1805,7 +1805,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_out_overlay))break ;
@@ -1813,43 +1813,43 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_s_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_out (file,NULL , arg); +return ops->vidioc_s_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_try_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);
@@ -1866,7 +1866,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_try_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )
@@ -1879,7 +1879,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_overlay))break ;
@@ -1887,22 +1887,22 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;
@@ -1913,7 +1913,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_out_overlay))break ;
@@ -1921,55 +1921,55 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_try_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_out (file,NULL , arg); +return ops->vidioc_try_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_streamon (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamon (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamon (file, state, *(unsigned int *)arg); }static int v4l_streamoff (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamoff (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamoff (file, state, *(unsigned int *)arg); }static int v4l_g_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;
@@ -1977,14 +1977,14 @@ static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, struct file *file, p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; - err = ops->vidioc_g_tuner (file,NULL , p); + err = ops->vidioc_g_tuner (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; }static int v4l_s_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;
@@ -1995,11 +1995,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, struct file *file,return ret; p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_s_tuner (file,NULL , p); +return ops->vidioc_s_tuner (file, state, p); } -static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;
@@ -2008,14 +2008,14 @@ static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; - err = ops->vidioc_g_modulator (file,NULL , p); + err = ops->vidioc_g_modulator (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; } -static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;
@@ -2023,11 +2023,11 @@ static int v4l_s_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; -return ops->vidioc_s_modulator (file,NULL , p); +return ops->vidioc_s_modulator (file, state, p); } -static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency *p = arg;
@@ -2037,11 +2037,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,else p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_g_frequency (file,NULL , p); +return ops->vidioc_g_frequency (file, state, p); } -static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);const struct v4l2_frequency *p = arg;
@@ -2060,11 +2060,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,if (type != p->type)return -EINVAL ; } -return ops->vidioc_s_frequency (file,NULL , p); +return ops->vidioc_s_frequency (file, state, p); }static int v4l_enumstd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_standard *p = arg;
@@ -2073,7 +2073,7 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_std (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id id = *(v4l2_std_id *)arg, norm;
@@ -2087,11 +2087,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, struct file *file,return -EINVAL ;/* Calls the specific handler */ -return ops->vidioc_s_std (file,NULL , norm); +return ops->vidioc_s_std (file, state, norm); }static int v4l_querystd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id *p = arg;
@@ -2109,11 +2109,12 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, struct file *file,* their efforts to improve the standards detection. */ *p = vfd->tvnorms; -return ops->vidioc_querystd (file,NULL , arg); +return ops->vidioc_querystd (file, state, arg); }static int v4l_s_hw_freq_seek (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_hw_freq_seek *p = arg;
@@ -2131,26 +2132,26 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;if (p->type != type)return -EINVAL ; -return ops->vidioc_s_hw_freq_seek (file,NULL , p); +return ops->vidioc_s_hw_freq_seek (file, state, p); }static int v4l_s_fbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_framebuffer *p = arg; p->base =NULL ; -return ops->vidioc_s_fbuf (file,NULL , p); +return ops->vidioc_s_fbuf (file, state, p); }static int v4l_overlay (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_overlay (file,NULL , *(unsigned int *)arg); +return ops->vidioc_overlay (file, state, *(unsigned int *)arg); }static int v4l_reqbufs (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_requestbuffers *p = arg;
@@ -2165,38 +2166,38 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, struct file *file,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) p->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; -return ops->vidioc_reqbufs (file,NULL , p); +return ops->vidioc_reqbufs (file, state, p); }static int v4l_querybuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_querybuf (file,NULL , p); +return ret ? ret : ops->vidioc_querybuf (file, state, p); }static int v4l_qbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_qbuf (file,NULL , p); +return ret ? ret : ops->vidioc_qbuf (file, state, p); }static int v4l_dqbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_dqbuf (file,NULL , p); +return ret ? ret : ops->vidioc_dqbuf (file, state, p); } -static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_create_buffers *create = arg;
@@ -2213,7 +2214,7 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) create->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; - ret = ops->vidioc_create_bufs (file,NULL , create); + ret = ops->vidioc_create_bufs (file, state, create);if (create->format.type ==V4L2_BUF_TYPE_VIDEO_CAPTURE || create->format.type ==V4L2_BUF_TYPE_VIDEO_OUTPUT )
@@ -2222,28 +2223,28 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,return ret; } -static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_buffer *b = arg;int ret =check_fmt (file, b->type); -return ret ? ret : ops->vidioc_prepare_buf (file,NULL , b); +return ret ? ret : ops->vidioc_prepare_buf (file, state, b); } -static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_remove_buffers *remove = arg;if (ops->vidioc_remove_bufs) -return ops->vidioc_remove_bufs (file,NULL , remove); +return ops->vidioc_remove_bufs (file, state, remove);return -ENOTTY ; }static int v4l_g_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_streamparm *p = arg;
@@ -2253,20 +2254,20 @@ static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file,if (ret)return ret;if (ops->vidioc_g_parm) -return ops->vidioc_g_parm (file,NULL , p); +return ops->vidioc_g_parm (file, state, p);if (p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE && p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE )return -EINVAL ;if (vfd->device_caps &V4L2_CAP_READWRITE ) p->parm.capture.readbuffers =2 ; - ret = ops->vidioc_g_std (file,NULL , &std); + ret = ops->vidioc_g_std (file, state, &std);if (ret ==0 )v4l2_video_std_frame_period (std, &p->parm.capture.timeperframe);return ret; }static int v4l_s_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_streamparm *p = arg;int ret =check_fmt (file, p->type);
@@ -2286,11 +2287,11 @@ static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, struct file *file, p->parm.capture.extendedmode =0 ; p->parm.capture.capturemode &=V4L2_MODE_HIGHQUALITY ; } -return ops->vidioc_s_parm (file,NULL , p); +return ops->vidioc_s_parm (file, state, p); }static int v4l_queryctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl qec = {};
@@ -2307,7 +2308,7 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file,/* Simulate query_ext_ctr using query_ctrl. */ qec.id = p->id; - ret = ops->vidioc_query_ext_ctrl (file,NULL , &qec); + ret = ops->vidioc_query_ext_ctrl (file, state, &qec);if (ret)return ret;v4l2_query_ext_ctrl_to_v4l2_queryctrl (p, &qec);
@@ -2315,7 +2316,8 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_query_ext_ctrl (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl *p = arg;
@@ -2326,12 +2328,12 @@ static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,if (vfd->ctrl_handler)return v4l2_query_ext_ctrl (vfd->ctrl_handler, p);if (ops->vidioc_query_ext_ctrl) -return ops->vidioc_query_ext_ctrl (file,NULL , p); +return ops->vidioc_query_ext_ctrl (file, state, p);return -ENOTTY ; }static int v4l_querymenu (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_querymenu *p = arg;
@@ -2342,12 +2344,12 @@ static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->ctrl_handler)return v4l2_querymenu (vfd->ctrl_handler, p);if (ops->vidioc_querymenu) -return ops->vidioc_querymenu (file,NULL , p); +return ops->vidioc_querymenu (file, state, p);return -ENOTTY ; }static int v4l_g_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;
@@ -2368,7 +2370,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.id = p->id; ctrl.value = p->value;if (check_ext_ctrls (&ctrls,VIDIOC_G_CTRL )) { -int ret = ops->vidioc_g_ext_ctrls (file,NULL , &ctrls); +int ret = ops->vidioc_g_ext_ctrls (file, state, &ctrls);if (ret ==0 ) p->value = ctrl.value;
@@ -2378,7 +2380,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;
@@ -2401,13 +2403,13 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.value = p->value;if (!check_ext_ctrls (&ctrls,VIDIOC_S_CTRL ))return -EINVAL ; - ret = ops->vidioc_s_ext_ctrls (file,NULL , &ctrls); + ret = ops->vidioc_s_ext_ctrls (file, state, &ctrls); p->value = ctrl.value;return ret; } -static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;
@@ -2423,11 +2425,11 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_g_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_G_EXT_CTRLS ) ? - ops->vidioc_g_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_g_ext_ctrls (file, state, p) : -EINVAL ; } -static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;
@@ -2443,11 +2445,12 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_s_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_S_EXT_CTRLS ) ? - ops->vidioc_s_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_s_ext_ctrls (file, state, p) : -EINVAL ; }static int v4l_try_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;
@@ -2463,7 +2466,7 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_try_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_TRY_EXT_CTRLS ) ? - ops->vidioc_try_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_try_ext_ctrls (file, state, p) : -EINVAL ; }/*
@@ -2475,8 +2478,8 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,* restore it afterwards. This way applications can use either buffer * type and drivers don't need to check for both. */ -static int v4l_g_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;
@@ -2486,13 +2489,13 @@ static int v4l_g_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_g_selection (file,NULL , p); + ret = ops->vidioc_g_selection (file, state, p); p->type = old_type;return ret; } -static int v4l_s_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;
@@ -2502,13 +2505,13 @@ static int v4l_s_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_s_selection (file,NULL , p); + ret = ops->vidioc_s_selection (file, state, p); p->type = old_type;return ret; }static int v4l_g_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;
@@ -2529,7 +2532,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);/* copying results to old structure on success */ if (!ret)
@@ -2538,7 +2541,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;
@@ -2559,11 +2562,11 @@ static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; -return v4l_s_selection (ops, file, &s); +return v4l_s_selection (ops, file, state, &s); }static int v4l_cropcap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_cropcap *p = arg;
@@ -2587,7 +2590,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,return -ENOTTY ;if (ops->vidioc_g_pixelaspect) - ret = ops->vidioc_g_pixelaspect (file,NULL , s.type, + ret = ops->vidioc_g_pixelaspect (file, state, s.type, &p->pixelaspect);/*
@@ -2609,7 +2612,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE_BOUNDS ?V4L2_SEL_TGT_CROP_BOUNDS :V4L2_SEL_TGT_COMPOSE_BOUNDS ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->bounds = s.r;
@@ -2620,7 +2623,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,else s.target =V4L2_SEL_TGT_CROP_DEFAULT ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->defrect = s.r;
@@ -2629,7 +2632,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_log_status (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;
@@ -2637,7 +2640,7 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->v4l2_dev)pr_info ("%s: ================= START STATUS =================\n" , vfd->v4l2_dev->name); - ret = ops->vidioc_log_status (file,NULL ); + ret = ops->vidioc_log_status (file, state);if (vfd->v4l2_dev)pr_info ("%s: ================== END STATUS ==================\n" , vfd->v4l2_dev->name);
@@ -2645,7 +2648,8 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_dbg_g_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct v4l2_dbg_register *p = arg;
@@ -2665,7 +2669,7 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_g_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_g_register (file,NULL , p); +return ops->vidioc_g_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;
@@ -2673,7 +2677,8 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_s_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG const struct v4l2_dbg_register *p = arg;
@@ -2693,7 +2698,7 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_s_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_s_register (file,NULL , p); +return ops->vidioc_s_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;
@@ -2701,7 +2706,8 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_g_chip_info (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct video_device *vfd =video_devdata (file);
@@ -2717,7 +2723,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, p->flags |=V4L2_CHIP_FL_READABLE ;strscpy (p->name, vfd->v4l2_dev->name,sizeof (p->name));if (ops->vidioc_g_chip_info) -return ops->vidioc_g_chip_info (file,NULL , arg); +return ops->vidioc_g_chip_info (file, state, arg);if (p->match.addr)return -EINVAL ;return 0 ;
@@ -2744,7 +2750,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, }static int v4l_dqevent (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);
@@ -2752,7 +2758,8 @@ static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_subscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);
@@ -2760,7 +2767,8 @@ static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_unsubscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);
@@ -2768,7 +2776,8 @@ static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_g_sliced_vbi_cap (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_sliced_vbi_cap *p = arg;int ret =check_fmt (file, p->type);
@@ -2779,11 +2788,12 @@ static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops,/* Clear up to type, everything after type is zeroed already */ memset (p,0 , offsetof(struct v4l2_sliced_vbi_cap , type)); -return ops->vidioc_g_sliced_vbi_cap (file,NULL , p); +return ops->vidioc_g_sliced_vbi_cap (file, state, p); }static int v4l_enum_freq_bands (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency_band *p = arg;
@@ -2801,7 +2811,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ; }if (ops->vidioc_enum_freq_bands) { - err = ops->vidioc_enum_freq_bands (file,NULL , p); + err = ops->vidioc_enum_freq_bands (file, state, p);if (err != -ENOTTY )return err; }
@@ -2813,7 +2823,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,if (p->index)return -EINVAL ; - err = ops->vidioc_g_tuner (file,NULL , &t); + err = ops->vidioc_g_tuner (file, state, &t);if (err)return err; p->capability = t.capability |V4L2_TUNER_CAP_FREQ_BANDS ;
@@ -2832,7 +2842,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ;if (p->index)return -EINVAL ; - err = ops->vidioc_g_modulator (file,NULL , &m); + err = ops->vidioc_g_modulator (file, state, &m);if (err)return err; p->capability = m.capability |V4L2_TUNER_CAP_FREQ_BANDS ;
@@ -2849,7 +2859,7 @@ struct v4l2_ioctl_info {u32 flags;const char *const name;int (*func)(const struct v4l2_ioctl_ops *ops,struct file *file, -void *p); +struct video_device_state *state,void *p);void (*debug)(const void *arg,bool write_only); };
@@ -2870,7 +2880,9 @@ struct v4l2_ioctl_info {#define DEFINE_V4L_STUB_FUNC (_vidioc) \ static int v4l_stub_ ## _vidioc( \ const struct v4l2_ioctl_ops *ops, \ - struct file *file, void *p) \ + struct file *file, \ + struct video_device_state *state, \ + void *p) \ { \ return ops->vidioc_ ## _vidioc(file, NULL, p); \ }
@@ -3126,7 +3138,7 @@ static long __video_do_ioctl(struct file *file, write_only =_IOC_DIR (cmd) == _IOC_WRITE;if (info != &default_info) { - ret = info->func (ops, file, arg); + ret = info->func (ops, file,NULL , arg); }else if (!ops->vidioc_default) { ret = -ENOTTY ; }else {
Signature · 1 line
2.51.0
Re: [PATCH v2 05/10] media: v4l2-ioctl: Add video_device_state argument to v4l2 ioctl wrappers
Quoted 7 lines · Jai Luthra
Add a third argument to all v4l2 ioctl wrappers to pass struct
video_device_state* directly, replacing the previous opaque pointer approach.Currently, this argument is populated with NULL since existing driver hooks still expect a void *priv argument. This will be addressed in a subsequent patch.
There is one more occurrance of this in v4l2_compat_ioctl32.c in function ctrl_is_pointer() where vidioc_query_ext_ctrl is called.
Regards,
Hans
Quoted 1,249 lines
Most changes to the ioctl wrappers were generated using the following Coccinelle semantic patch:
@ioctl@
identifierv4l2_ioctls;
identifier ioctl;
identifier fn;
identifier debug;
expression flags;
@@struct v4l2_ioctl_info v4l2_ioctls[] = { ..., IOCTL_INFO(ioctl, fn, debug, flags), ..., };@depends on ioctl@
identifier ioctl.fn;
identifier ops;
identifier file;
identifier arg;
identifier handler;
expression list args;
@@(quoted diff) +2
-1-int fn(const struct v4l2_ioctl_ops *ops, struct file *file, void *arg) +int fn(const struct v4l2_ioctl_ops *ops, struct file *file, + struct video_device_state *state, void *arg){ <...(quoted diff) +1
-1- ops->handler(file, NULL, args) + ops->handler(file, state, args)...> }Manual changes were made to handle calls to v4l_[gs]_selection, update the
v4l2_ioctl_infostructure definition and macros, fix argument wrapping in some function definitions, and handle the common function pointer inv4l2_ioctl_info.Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-ioctl.c | 360 ++++++++++++++++++----------------- 1 file changed, 186 insertions(+), 174 deletions(-)drivers/media/v4l2-core/v4l2-ioctl.c +186
-174@@ -1090,7 +1090,7 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) }static int v4l_querycap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_capability *cap = (struct v4l2_capability *)arg;struct video_device *vfd =video_devdata (file);@@ -1103,7 +1103,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file,media_set_bus_info (cap->bus_info,sizeof (cap->bus_info), vfd->dev_parent); - ret = ops->vidioc_querycap (file,NULL , cap); + ret = ops->vidioc_querycap (file, state, cap);/* * Drivers must not change device_caps, so check for this and @@ -1124,7 +1124,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_g_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);@@ -1133,11 +1133,11 @@ static int v4l_g_input(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_input (file,NULL , arg); +return ops->vidioc_g_input (file, state, arg); }static int v4l_g_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);@@ -1146,11 +1146,11 @@ static int v4l_g_output(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_output (file,NULL , arg); +return ops->vidioc_g_output (file, state, arg); }static int v4l_s_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;@@ -1162,22 +1162,22 @@ static int v4l_s_input(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_input (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_input (file, state, *(unsigned int *)arg); }static int v4l_s_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_output (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_output (file, state, *(unsigned int *)arg); }static int v4l_g_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;u32 *p = arg;@@ -1188,7 +1188,7 @@ static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;struct v4l2_fh *vfh;@@ -1200,7 +1200,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_enuminput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_input *p = arg;@@ -1222,11 +1222,11 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_input (file,NULL , p); +return ops->vidioc_enum_input (file, state, p); }static int v4l_enumoutput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_output *p = arg;@@ -1248,7 +1248,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_output (file,NULL , p); +return ops->vidioc_enum_output (file, state, p); }static void v4l_fill_fmtdesc (struct v4l2_fmtdesc *fmt)@@ -1588,7 +1588,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) }static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;@@ -1618,12 +1618,12 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_cap))break ; - ret = ops->vidioc_enum_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_cap (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_enum_fmt_vid_overlay))break ; - ret = ops->vidioc_enum_fmt_vid_overlay (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_overlay (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE :@@ -1635,27 +1635,27 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_out))break ; - ret = ops->vidioc_enum_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_out (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_sdr_cap))break ; - ret = ops->vidioc_enum_fmt_sdr_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_cap (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_sdr_out))break ; - ret = ops->vidioc_enum_fmt_sdr_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_out (file, state, arg);break ;case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_meta_cap))break ; - ret = ops->vidioc_enum_fmt_meta_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_cap (file, state, arg);break ;case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_meta_out))break ; - ret = ops->vidioc_enum_fmt_meta_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_out (file, state, arg);break ; }if (ret ==0 )@@ -1679,7 +1679,7 @@ static void v4l_pix_format_touch(struct v4l2_pix_format *p) }static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1695,50 +1695,50 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_g_fmt_vid_cap))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )v4l_pix_format_touch (&p->fmt.pix);return ret;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -return ops->vidioc_g_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY : -return ops->vidioc_g_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE : -return ops->vidioc_g_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : -return ops->vidioc_g_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_g_fmt_vid_out))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -return ops->vidioc_g_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY : -return ops->vidioc_g_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT : -return ops->vidioc_g_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : -return ops->vidioc_g_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE : -return ops->vidioc_g_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT : -return ops->vidioc_g_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE : -return ops->vidioc_g_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_g_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT : -return ops->vidioc_g_fmt_meta_out (file,NULL , arg); +return ops->vidioc_g_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_s_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1758,7 +1758,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_s_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )@@ -1771,7 +1771,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_overlay))break ;@@ -1779,22 +1779,22 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;@@ -1805,7 +1805,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_out_overlay))break ;@@ -1813,43 +1813,43 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_s_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_out (file,NULL , arg); +return ops->vidioc_s_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_try_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1866,7 +1866,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_try_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )@@ -1879,7 +1879,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_overlay))break ;@@ -1887,22 +1887,22 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;@@ -1913,7 +1913,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_out_overlay))break ;@@ -1921,55 +1921,55 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_try_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_out (file,NULL , arg); +return ops->vidioc_try_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_streamon (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamon (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamon (file, state, *(unsigned int *)arg); }static int v4l_streamoff (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamoff (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamoff (file, state, *(unsigned int *)arg); }static int v4l_g_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;@@ -1977,14 +1977,14 @@ static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, struct file *file, p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; - err = ops->vidioc_g_tuner (file,NULL , p); + err = ops->vidioc_g_tuner (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; }static int v4l_s_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;@@ -1995,11 +1995,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, struct file *file,return ret; p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_s_tuner (file,NULL , p); +return ops->vidioc_s_tuner (file, state, p); } -static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;@@ -2008,14 +2008,14 @@ static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; - err = ops->vidioc_g_modulator (file,NULL , p); + err = ops->vidioc_g_modulator (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; } -static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;@@ -2023,11 +2023,11 @@ static int v4l_s_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; -return ops->vidioc_s_modulator (file,NULL , p); +return ops->vidioc_s_modulator (file, state, p); } -static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency *p = arg;@@ -2037,11 +2037,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,else p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_g_frequency (file,NULL , p); +return ops->vidioc_g_frequency (file, state, p); } -static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);const struct v4l2_frequency *p = arg;@@ -2060,11 +2060,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,if (type != p->type)return -EINVAL ; } -return ops->vidioc_s_frequency (file,NULL , p); +return ops->vidioc_s_frequency (file, state, p); }static int v4l_enumstd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_standard *p = arg;@@ -2073,7 +2073,7 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_std (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id id = *(v4l2_std_id *)arg, norm;@@ -2087,11 +2087,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, struct file *file,return -EINVAL ;/* Calls the specific handler */ -return ops->vidioc_s_std (file,NULL , norm); +return ops->vidioc_s_std (file, state, norm); }static int v4l_querystd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id *p = arg;@@ -2109,11 +2109,12 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, struct file *file,* their efforts to improve the standards detection. */ *p = vfd->tvnorms; -return ops->vidioc_querystd (file,NULL , arg); +return ops->vidioc_querystd (file, state, arg); }static int v4l_s_hw_freq_seek (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_hw_freq_seek *p = arg;@@ -2131,26 +2132,26 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;if (p->type != type)return -EINVAL ; -return ops->vidioc_s_hw_freq_seek (file,NULL , p); +return ops->vidioc_s_hw_freq_seek (file, state, p); }static int v4l_s_fbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_framebuffer *p = arg; p->base =NULL ; -return ops->vidioc_s_fbuf (file,NULL , p); +return ops->vidioc_s_fbuf (file, state, p); }static int v4l_overlay (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_overlay (file,NULL , *(unsigned int *)arg); +return ops->vidioc_overlay (file, state, *(unsigned int *)arg); }static int v4l_reqbufs (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_requestbuffers *p = arg;@@ -2165,38 +2166,38 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, struct file *file,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) p->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; -return ops->vidioc_reqbufs (file,NULL , p); +return ops->vidioc_reqbufs (file, state, p); }static int v4l_querybuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_querybuf (file,NULL , p); +return ret ? ret : ops->vidioc_querybuf (file, state, p); }static int v4l_qbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_qbuf (file,NULL , p); +return ret ? ret : ops->vidioc_qbuf (file, state, p); }static int v4l_dqbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_dqbuf (file,NULL , p); +return ret ? ret : ops->vidioc_dqbuf (file, state, p); } -static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_create_buffers *create = arg;@@ -2213,7 +2214,7 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) create->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; - ret = ops->vidioc_create_bufs (file,NULL , create); + ret = ops->vidioc_create_bufs (file, state, create);if (create->format.type ==V4L2_BUF_TYPE_VIDEO_CAPTURE || create->format.type ==V4L2_BUF_TYPE_VIDEO_OUTPUT )@@ -2222,28 +2223,28 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,return ret; } -static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_buffer *b = arg;int ret =check_fmt (file, b->type); -return ret ? ret : ops->vidioc_prepare_buf (file,NULL , b); +return ret ? ret : ops->vidioc_prepare_buf (file, state, b); } -static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_remove_buffers *remove = arg;if (ops->vidioc_remove_bufs) -return ops->vidioc_remove_bufs (file,NULL , remove); +return ops->vidioc_remove_bufs (file, state, remove);return -ENOTTY ; }static int v4l_g_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_streamparm *p = arg;@@ -2253,20 +2254,20 @@ static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file,if (ret)return ret;if (ops->vidioc_g_parm) -return ops->vidioc_g_parm (file,NULL , p); +return ops->vidioc_g_parm (file, state, p);if (p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE && p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE )return -EINVAL ;if (vfd->device_caps &V4L2_CAP_READWRITE ) p->parm.capture.readbuffers =2 ; - ret = ops->vidioc_g_std (file,NULL , &std); + ret = ops->vidioc_g_std (file, state, &std);if (ret ==0 )v4l2_video_std_frame_period (std, &p->parm.capture.timeperframe);return ret; }static int v4l_s_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_streamparm *p = arg;int ret =check_fmt (file, p->type);@@ -2286,11 +2287,11 @@ static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, struct file *file, p->parm.capture.extendedmode =0 ; p->parm.capture.capturemode &=V4L2_MODE_HIGHQUALITY ; } -return ops->vidioc_s_parm (file,NULL , p); +return ops->vidioc_s_parm (file, state, p); }static int v4l_queryctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl qec = {};@@ -2307,7 +2308,7 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file,/* Simulate query_ext_ctr using query_ctrl. */ qec.id = p->id; - ret = ops->vidioc_query_ext_ctrl (file,NULL , &qec); + ret = ops->vidioc_query_ext_ctrl (file, state, &qec);if (ret)return ret;v4l2_query_ext_ctrl_to_v4l2_queryctrl (p, &qec);@@ -2315,7 +2316,8 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_query_ext_ctrl (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl *p = arg;@@ -2326,12 +2328,12 @@ static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,if (vfd->ctrl_handler)return v4l2_query_ext_ctrl (vfd->ctrl_handler, p);if (ops->vidioc_query_ext_ctrl) -return ops->vidioc_query_ext_ctrl (file,NULL , p); +return ops->vidioc_query_ext_ctrl (file, state, p);return -ENOTTY ; }static int v4l_querymenu (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_querymenu *p = arg;@@ -2342,12 +2344,12 @@ static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->ctrl_handler)return v4l2_querymenu (vfd->ctrl_handler, p);if (ops->vidioc_querymenu) -return ops->vidioc_querymenu (file,NULL , p); +return ops->vidioc_querymenu (file, state, p);return -ENOTTY ; }static int v4l_g_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;@@ -2368,7 +2370,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.id = p->id; ctrl.value = p->value;if (check_ext_ctrls (&ctrls,VIDIOC_G_CTRL )) { -int ret = ops->vidioc_g_ext_ctrls (file,NULL , &ctrls); +int ret = ops->vidioc_g_ext_ctrls (file, state, &ctrls);if (ret ==0 ) p->value = ctrl.value;@@ -2378,7 +2380,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;@@ -2401,13 +2403,13 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.value = p->value;if (!check_ext_ctrls (&ctrls,VIDIOC_S_CTRL ))return -EINVAL ; - ret = ops->vidioc_s_ext_ctrls (file,NULL , &ctrls); + ret = ops->vidioc_s_ext_ctrls (file, state, &ctrls); p->value = ctrl.value;return ret; } -static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2423,11 +2425,11 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_g_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_G_EXT_CTRLS ) ? - ops->vidioc_g_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_g_ext_ctrls (file, state, p) : -EINVAL ; } -static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2443,11 +2445,12 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_s_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_S_EXT_CTRLS ) ? - ops->vidioc_s_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_s_ext_ctrls (file, state, p) : -EINVAL ; }static int v4l_try_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2463,7 +2466,7 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_try_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_TRY_EXT_CTRLS ) ? - ops->vidioc_try_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_try_ext_ctrls (file, state, p) : -EINVAL ; }/* @@ -2475,8 +2478,8 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,* restore it afterwards. This way applications can use either buffer * type and drivers don't need to check for both. */ -static int v4l_g_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;@@ -2486,13 +2489,13 @@ static int v4l_g_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_g_selection (file,NULL , p); + ret = ops->vidioc_g_selection (file, state, p); p->type = old_type;return ret; } -static int v4l_s_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;@@ -2502,13 +2505,13 @@ static int v4l_s_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_s_selection (file,NULL , p); + ret = ops->vidioc_s_selection (file, state, p); p->type = old_type;return ret; }static int v4l_g_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;@@ -2529,7 +2532,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);/* copying results to old structure on success */ if (!ret)@@ -2538,7 +2541,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;@@ -2559,11 +2562,11 @@ static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; -return v4l_s_selection (ops, file, &s); +return v4l_s_selection (ops, file, state, &s); }static int v4l_cropcap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_cropcap *p = arg;@@ -2587,7 +2590,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,return -ENOTTY ;if (ops->vidioc_g_pixelaspect) - ret = ops->vidioc_g_pixelaspect (file,NULL , s.type, + ret = ops->vidioc_g_pixelaspect (file, state, s.type, &p->pixelaspect);/* @@ -2609,7 +2612,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE_BOUNDS ?V4L2_SEL_TGT_CROP_BOUNDS :V4L2_SEL_TGT_COMPOSE_BOUNDS ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->bounds = s.r;@@ -2620,7 +2623,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,else s.target =V4L2_SEL_TGT_CROP_DEFAULT ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->defrect = s.r;@@ -2629,7 +2632,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_log_status (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;@@ -2637,7 +2640,7 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->v4l2_dev)pr_info ("%s: ================= START STATUS =================\n" , vfd->v4l2_dev->name); - ret = ops->vidioc_log_status (file,NULL ); + ret = ops->vidioc_log_status (file, state);if (vfd->v4l2_dev)pr_info ("%s: ================== END STATUS ==================\n" , vfd->v4l2_dev->name);@@ -2645,7 +2648,8 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_dbg_g_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct v4l2_dbg_register *p = arg;@@ -2665,7 +2669,7 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_g_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_g_register (file,NULL , p); +return ops->vidioc_g_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;@@ -2673,7 +2677,8 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_s_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG const struct v4l2_dbg_register *p = arg;@@ -2693,7 +2698,7 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_s_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_s_register (file,NULL , p); +return ops->vidioc_s_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;@@ -2701,7 +2706,8 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_g_chip_info (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct video_device *vfd =video_devdata (file);@@ -2717,7 +2723,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, p->flags |=V4L2_CHIP_FL_READABLE ;strscpy (p->name, vfd->v4l2_dev->name,sizeof (p->name));if (ops->vidioc_g_chip_info) -return ops->vidioc_g_chip_info (file,NULL , arg); +return ops->vidioc_g_chip_info (file, state, arg);if (p->match.addr)return -EINVAL ;return 0 ;@@ -2744,7 +2750,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, }static int v4l_dqevent (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2752,7 +2758,8 @@ static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_subscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2760,7 +2767,8 @@ static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_unsubscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2768,7 +2776,8 @@ static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_g_sliced_vbi_cap (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_sliced_vbi_cap *p = arg;int ret =check_fmt (file, p->type);@@ -2779,11 +2788,12 @@ static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops,/* Clear up to type, everything after type is zeroed already */ memset (p,0 , offsetof(struct v4l2_sliced_vbi_cap , type)); -return ops->vidioc_g_sliced_vbi_cap (file,NULL , p); +return ops->vidioc_g_sliced_vbi_cap (file, state, p); }static int v4l_enum_freq_bands (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency_band *p = arg;@@ -2801,7 +2811,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ; }if (ops->vidioc_enum_freq_bands) { - err = ops->vidioc_enum_freq_bands (file,NULL , p); + err = ops->vidioc_enum_freq_bands (file, state, p);if (err != -ENOTTY )return err; }@@ -2813,7 +2823,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,if (p->index)return -EINVAL ; - err = ops->vidioc_g_tuner (file,NULL , &t); + err = ops->vidioc_g_tuner (file, state, &t);if (err)return err; p->capability = t.capability |V4L2_TUNER_CAP_FREQ_BANDS ;@@ -2832,7 +2842,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ;if (p->index)return -EINVAL ; - err = ops->vidioc_g_modulator (file,NULL , &m); + err = ops->vidioc_g_modulator (file, state, &m);if (err)return err; p->capability = m.capability |V4L2_TUNER_CAP_FREQ_BANDS ;@@ -2849,7 +2859,7 @@ struct v4l2_ioctl_info {u32 flags;const char *const name;int (*func)(const struct v4l2_ioctl_ops *ops,struct file *file, -void *p); +struct video_device_state *state,void *p);void (*debug)(const void *arg,bool write_only); };@@ -2870,7 +2880,9 @@ struct v4l2_ioctl_info {#define DEFINE_V4L_STUB_FUNC (_vidioc) \ static int v4l_stub_ ## _vidioc( \ const struct v4l2_ioctl_ops *ops, \ - struct file *file, void *p) \ + struct file *file, \ + struct video_device_state *state, \ + void *p) \ { \ return ops->vidioc_ ## _vidioc(file, NULL, p); \ }@@ -3126,7 +3138,7 @@ static long __video_do_ioctl(struct file *file, write_only =_IOC_DIR (cmd) == _IOC_WRITE;if (info != &default_info) { - ret = info->func (ops, file, arg); + ret = info->func (ops, file,NULL , arg); }else if (!ops->vidioc_default) { ret = -ENOTTY ; }else {
Re: [PATCH v2 05/10] media: v4l2-ioctl: Add video_device_state argument to v4l2 ioctl wrappers
Quoted 11 lines · Hans Verkuil
Quoted 7 lines · Jai Luthra
Add a third argument to all v4l2 ioctl wrappers to pass struct
video_device_state* directly, replacing the previous opaque pointer approach.Currently, this argument is populated with NULL since existing driver hooks still expect a void *priv argument. This will be addressed in a subsequent patch.
There is one more occurrance of this in
v4l2_compat_ioctl32.cin functionctrl_is_pointer()wherevidioc_query_ext_ctrlis called.
Ignore this, this doesn't apply to this patch.
Quoted 1,256 lines
Regards,
Hans
Quoted 1,249 lines
Most changes to the ioctl wrappers were generated using the following Coccinelle semantic patch:
@ioctl@
identifierv4l2_ioctls;
identifier ioctl;
identifier fn;
identifier debug;
expression flags;
@@struct v4l2_ioctl_info v4l2_ioctls[] = { ..., IOCTL_INFO(ioctl, fn, debug, flags), ..., };@depends on ioctl@
identifier ioctl.fn;
identifier ops;
identifier file;
identifier arg;
identifier handler;
expression list args;
@@(quoted diff) +2
-1-int fn(const struct v4l2_ioctl_ops *ops, struct file *file, void *arg) +int fn(const struct v4l2_ioctl_ops *ops, struct file *file, + struct video_device_state *state, void *arg){ <...(quoted diff) +1
-1- ops->handler(file, NULL, args) + ops->handler(file, state, args)...> }Manual changes were made to handle calls to v4l_[gs]_selection, update the
v4l2_ioctl_infostructure definition and macros, fix argument wrapping in some function definitions, and handle the common function pointer inv4l2_ioctl_info.Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]--- drivers/media/v4l2-core/v4l2-ioctl.c | 360 ++++++++++++++++++----------------- 1 file changed, 186 insertions(+), 174 deletions(-)drivers/media/v4l2-core/v4l2-ioctl.c +186
-174@@ -1090,7 +1090,7 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) }static int v4l_querycap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_capability *cap = (struct v4l2_capability *)arg;struct video_device *vfd =video_devdata (file);@@ -1103,7 +1103,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file,media_set_bus_info (cap->bus_info,sizeof (cap->bus_info), vfd->dev_parent); - ret = ops->vidioc_querycap (file,NULL , cap); + ret = ops->vidioc_querycap (file, state, cap);/* * Drivers must not change device_caps, so check for this and @@ -1124,7 +1124,7 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_g_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);@@ -1133,11 +1133,11 @@ static int v4l_g_input(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_input (file,NULL , arg); +return ops->vidioc_g_input (file, state, arg); }static int v4l_g_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);@@ -1146,11 +1146,11 @@ static int v4l_g_output(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_g_output (file,NULL , arg); +return ops->vidioc_g_output (file, state, arg); }static int v4l_s_input (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;@@ -1162,22 +1162,22 @@ static int v4l_s_input(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_input (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_input (file, state, *(unsigned int *)arg); }static int v4l_s_output (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);if (vfd->device_caps &V4L2_CAP_IO_MC )return *(int *)arg ? -EINVAL :0 ; -return ops->vidioc_s_output (file,NULL , *(unsigned int *)arg); +return ops->vidioc_s_output (file, state, *(unsigned int *)arg); }static int v4l_g_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;u32 *p = arg;@@ -1188,7 +1188,7 @@ static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_priority (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd;struct v4l2_fh *vfh;@@ -1200,7 +1200,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_enuminput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_input *p = arg;@@ -1222,11 +1222,11 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_input (file,NULL , p); +return ops->vidioc_enum_input (file, state, p); }static int v4l_enumoutput (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_output *p = arg;@@ -1248,7 +1248,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, struct file *file,return 0 ; } -return ops->vidioc_enum_output (file,NULL , p); +return ops->vidioc_enum_output (file, state, p); }static void v4l_fill_fmtdesc (struct v4l2_fmtdesc *fmt)@@ -1588,7 +1588,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) }static int v4l_enum_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vdev =video_devdata (file);struct v4l2_fmtdesc *p = arg;@@ -1618,12 +1618,12 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_cap))break ; - ret = ops->vidioc_enum_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_cap (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_enum_fmt_vid_overlay))break ; - ret = ops->vidioc_enum_fmt_vid_overlay (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_overlay (file, state, arg);break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT :case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE :@@ -1635,27 +1635,27 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_enum_fmt_vid_out))break ; - ret = ops->vidioc_enum_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_vid_out (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_sdr_cap))break ; - ret = ops->vidioc_enum_fmt_sdr_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_cap (file, state, arg);break ;case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_sdr_out))break ; - ret = ops->vidioc_enum_fmt_sdr_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_sdr_out (file, state, arg);break ;case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_enum_fmt_meta_cap))break ; - ret = ops->vidioc_enum_fmt_meta_cap (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_cap (file, state, arg);break ;case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_enum_fmt_meta_out))break ; - ret = ops->vidioc_enum_fmt_meta_out (file,NULL , arg); + ret = ops->vidioc_enum_fmt_meta_out (file, state, arg);break ; }if (ret ==0 )@@ -1679,7 +1679,7 @@ static void v4l_pix_format_touch(struct v4l2_pix_format *p) }static int v4l_g_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1695,50 +1695,50 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_g_fmt_vid_cap))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )v4l_pix_format_touch (&p->fmt.pix);return ret;case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : -return ops->vidioc_g_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY : -return ops->vidioc_g_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE : -return ops->vidioc_g_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE : -return ops->vidioc_g_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_g_fmt_vid_out))break ; p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ; - ret = ops->vidioc_g_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_g_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : -return ops->vidioc_g_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY : -return ops->vidioc_g_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_g_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT : -return ops->vidioc_g_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT : -return ops->vidioc_g_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_g_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE : -return ops->vidioc_g_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT : -return ops->vidioc_g_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_g_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE : -return ops->vidioc_g_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_g_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT : -return ops->vidioc_g_fmt_meta_out (file,NULL , arg); +return ops->vidioc_g_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_s_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1758,7 +1758,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_s_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )@@ -1771,7 +1771,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_overlay))break ;@@ -1779,22 +1779,22 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_s_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_s_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;@@ -1805,7 +1805,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_s_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_s_fmt_vid_out_overlay))break ;@@ -1813,43 +1813,43 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_s_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_s_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_s_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_s_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_s_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_s_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_s_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_s_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_s_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_s_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_s_fmt_meta_out (file,NULL , arg); +return ops->vidioc_s_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_try_fmt (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);@@ -1866,7 +1866,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,if (unlikely (!ops->vidioc_try_fmt_vid_cap))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_cap (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_cap (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;if (vfd->vfl_type ==VFL_TYPE_TOUCH )@@ -1879,7 +1879,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_cap_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_cap_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_overlay))break ;@@ -1887,22 +1887,22 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_vbi_cap))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_cap))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_cap (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vid_out))break ;memset_after (p,0 , fmt.pix); - ret = ops->vidioc_try_fmt_vid_out (file,NULL , arg); + ret = ops->vidioc_try_fmt_vid_out (file, state, arg);/* just in case the driver zeroed it again */ p->fmt.pix.priv =V4L2_PIX_FMT_PRIV_MAGIC ;return ret;@@ -1913,7 +1913,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file,for (i =0 ; i < p->fmt.pix_mp.num_planes; i++)memset_after (&p->fmt.pix_mp.plane_fmt[i],0 , bytesperline); -return ops->vidioc_try_fmt_vid_out_mplane (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_mplane (file, state, arg);case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY :if (unlikely (!ops->vidioc_try_fmt_vid_out_overlay))break ;@@ -1921,55 +1921,55 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, struct file *file, p->fmt.win.clips =NULL ; p->fmt.win.clipcount =0 ; p->fmt.win.bitmap =NULL ; -return ops->vidioc_try_fmt_vid_out_overlay (file,NULL , arg); +return ops->vidioc_try_fmt_vid_out_overlay (file, state, arg);case V4L2_BUF_TYPE_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_vbi_out))break ;memset_after (p,0 , fmt.vbi.flags); -return ops->vidioc_try_fmt_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sliced_vbi_out))break ;memset_after (p,0 , fmt.sliced.io_size); -return ops->vidioc_try_fmt_sliced_vbi_out (file,NULL , arg); +return ops->vidioc_try_fmt_sliced_vbi_out (file, state, arg);case V4L2_BUF_TYPE_SDR_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_sdr_cap))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_cap (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_cap (file, state, arg);case V4L2_BUF_TYPE_SDR_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_sdr_out))break ;memset_after (p,0 , fmt.sdr.buffersize); -return ops->vidioc_try_fmt_sdr_out (file,NULL , arg); +return ops->vidioc_try_fmt_sdr_out (file, state, arg);case V4L2_BUF_TYPE_META_CAPTURE :if (unlikely (!ops->vidioc_try_fmt_meta_cap))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_cap (file,NULL , arg); +return ops->vidioc_try_fmt_meta_cap (file, state, arg);case V4L2_BUF_TYPE_META_OUTPUT :if (unlikely (!ops->vidioc_try_fmt_meta_out))break ;memset_after (p,0 , fmt.meta); -return ops->vidioc_try_fmt_meta_out (file,NULL , arg); +return ops->vidioc_try_fmt_meta_out (file, state, arg); }return -EINVAL ; }static int v4l_streamon (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamon (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamon (file, state, *(unsigned int *)arg); }static int v4l_streamoff (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_streamoff (file,NULL , *(unsigned int *)arg); +return ops->vidioc_streamoff (file, state, *(unsigned int *)arg); }static int v4l_g_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;@@ -1977,14 +1977,14 @@ static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, struct file *file, p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; - err = ops->vidioc_g_tuner (file,NULL , p); + err = ops->vidioc_g_tuner (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; }static int v4l_s_tuner (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg;@@ -1995,11 +1995,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, struct file *file,return ret; p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_s_tuner (file,NULL , p); +return ops->vidioc_s_tuner (file, state, p); } -static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;@@ -2008,14 +2008,14 @@ static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; - err = ops->vidioc_g_modulator (file,NULL , p); + err = ops->vidioc_g_modulator (file, state, p);if (!err) p->capability |=V4L2_TUNER_CAP_FREQ_BANDS ;return err; } -static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_modulator (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_modulator *p = arg;@@ -2023,11 +2023,11 @@ static int v4l_s_modulator(const struct v4l2_ioctl_ops *ops,if (vfd->vfl_type ==VFL_TYPE_RADIO ) p->type =V4L2_TUNER_RADIO ; -return ops->vidioc_s_modulator (file,NULL , p); +return ops->vidioc_s_modulator (file, state, p); } -static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency *p = arg;@@ -2037,11 +2037,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,else p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -return ops->vidioc_g_frequency (file,NULL , p); +return ops->vidioc_g_frequency (file, state, p); } -static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_frequency (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);const struct v4l2_frequency *p = arg;@@ -2060,11 +2060,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,if (type != p->type)return -EINVAL ; } -return ops->vidioc_s_frequency (file,NULL , p); +return ops->vidioc_s_frequency (file, state, p); }static int v4l_enumstd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_standard *p = arg;@@ -2073,7 +2073,7 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_std (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id id = *(v4l2_std_id *)arg, norm;@@ -2087,11 +2087,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, struct file *file,return -EINVAL ;/* Calls the specific handler */ -return ops->vidioc_s_std (file,NULL , norm); +return ops->vidioc_s_std (file, state, norm); }static int v4l_querystd (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);v4l2_std_id *p = arg;@@ -2109,11 +2109,12 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, struct file *file,* their efforts to improve the standards detection. */ *p = vfd->tvnorms; -return ops->vidioc_querystd (file,NULL , arg); +return ops->vidioc_querystd (file, state, arg); }static int v4l_s_hw_freq_seek (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_hw_freq_seek *p = arg;@@ -2131,26 +2132,26 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;if (p->type != type)return -EINVAL ; -return ops->vidioc_s_hw_freq_seek (file,NULL , p); +return ops->vidioc_s_hw_freq_seek (file, state, p); }static int v4l_s_fbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_framebuffer *p = arg; p->base =NULL ; -return ops->vidioc_s_fbuf (file,NULL , p); +return ops->vidioc_s_fbuf (file, state, p); }static int v4l_overlay (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) { -return ops->vidioc_overlay (file,NULL , *(unsigned int *)arg); +return ops->vidioc_overlay (file, state, *(unsigned int *)arg); }static int v4l_reqbufs (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_requestbuffers *p = arg;@@ -2165,38 +2166,38 @@ static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, struct file *file,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) p->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; -return ops->vidioc_reqbufs (file,NULL , p); +return ops->vidioc_reqbufs (file, state, p); }static int v4l_querybuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_querybuf (file,NULL , p); +return ret ? ret : ops->vidioc_querybuf (file, state, p); }static int v4l_qbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_qbuf (file,NULL , p); +return ret ? ret : ops->vidioc_qbuf (file, state, p); }static int v4l_dqbuf (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_buffer *p = arg;int ret =check_fmt (file, p->type); -return ret ? ret : ops->vidioc_dqbuf (file,NULL , p); +return ret ? ret : ops->vidioc_dqbuf (file, state, p); } -static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_create_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_create_buffers *create = arg;@@ -2213,7 +2214,7 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,if (is_valid_ioctl (vfd,VIDIOC_REMOVE_BUFS )) create->capabilities =V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS ; - ret = ops->vidioc_create_bufs (file,NULL , create); + ret = ops->vidioc_create_bufs (file, state, create);if (create->format.type ==V4L2_BUF_TYPE_VIDEO_CAPTURE || create->format.type ==V4L2_BUF_TYPE_VIDEO_OUTPUT )@@ -2222,28 +2223,28 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,return ret; } -static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_prepare_buf (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_buffer *b = arg;int ret =check_fmt (file, b->type); -return ret ? ret : ops->vidioc_prepare_buf (file,NULL , b); +return ret ? ret : ops->vidioc_prepare_buf (file, state, b); } -static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_remove_bufs (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_remove_buffers *remove = arg;if (ops->vidioc_remove_bufs) -return ops->vidioc_remove_bufs (file,NULL , remove); +return ops->vidioc_remove_bufs (file, state, remove);return -ENOTTY ; }static int v4l_g_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_streamparm *p = arg;@@ -2253,20 +2254,20 @@ static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file,if (ret)return ret;if (ops->vidioc_g_parm) -return ops->vidioc_g_parm (file,NULL , p); +return ops->vidioc_g_parm (file, state, p);if (p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE && p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE )return -EINVAL ;if (vfd->device_caps &V4L2_CAP_READWRITE ) p->parm.capture.readbuffers =2 ; - ret = ops->vidioc_g_std (file,NULL , &std); + ret = ops->vidioc_g_std (file, state, &std);if (ret ==0 )v4l2_video_std_frame_period (std, &p->parm.capture.timeperframe);return ret; }static int v4l_s_parm (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_streamparm *p = arg;int ret =check_fmt (file, p->type);@@ -2286,11 +2287,11 @@ static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, struct file *file, p->parm.capture.extendedmode =0 ; p->parm.capture.capturemode &=V4L2_MODE_HIGHQUALITY ; } -return ops->vidioc_s_parm (file,NULL , p); +return ops->vidioc_s_parm (file, state, p); }static int v4l_queryctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl qec = {};@@ -2307,7 +2308,7 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file,/* Simulate query_ext_ctr using query_ctrl. */ qec.id = p->id; - ret = ops->vidioc_query_ext_ctrl (file,NULL , &qec); + ret = ops->vidioc_query_ext_ctrl (file, state, &qec);if (ret)return ret;v4l2_query_ext_ctrl_to_v4l2_queryctrl (p, &qec);@@ -2315,7 +2316,8 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_query_ext_ctrl (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_query_ext_ctrl *p = arg;@@ -2326,12 +2328,12 @@ static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,if (vfd->ctrl_handler)return v4l2_query_ext_ctrl (vfd->ctrl_handler, p);if (ops->vidioc_query_ext_ctrl) -return ops->vidioc_query_ext_ctrl (file,NULL , p); +return ops->vidioc_query_ext_ctrl (file, state, p);return -ENOTTY ; }static int v4l_querymenu (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_querymenu *p = arg;@@ -2342,12 +2344,12 @@ static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->ctrl_handler)return v4l2_querymenu (vfd->ctrl_handler, p);if (ops->vidioc_querymenu) -return ops->vidioc_querymenu (file,NULL , p); +return ops->vidioc_querymenu (file, state, p);return -ENOTTY ; }static int v4l_g_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;@@ -2368,7 +2370,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.id = p->id; ctrl.value = p->value;if (check_ext_ctrls (&ctrls,VIDIOC_G_CTRL )) { -int ret = ops->vidioc_g_ext_ctrls (file,NULL , &ctrls); +int ret = ops->vidioc_g_ext_ctrls (file, state, &ctrls);if (ret ==0 ) p->value = ctrl.value;@@ -2378,7 +2380,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_ctrl (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_control *p = arg;@@ -2401,13 +2403,13 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, struct file *file, ctrl.value = p->value;if (!check_ext_ctrls (&ctrls,VIDIOC_S_CTRL ))return -EINVAL ; - ret = ops->vidioc_s_ext_ctrls (file,NULL , &ctrls); + ret = ops->vidioc_s_ext_ctrls (file, state, &ctrls); p->value = ctrl.value;return ret; } -static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2423,11 +2425,11 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_g_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_G_EXT_CTRLS ) ? - ops->vidioc_g_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_g_ext_ctrls (file, state, p) : -EINVAL ; } -static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_ext_ctrls (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2443,11 +2445,12 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_s_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_S_EXT_CTRLS ) ? - ops->vidioc_s_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_s_ext_ctrls (file, state, p) : -EINVAL ; }static int v4l_try_ext_ctrls (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_ext_controls *p = arg;@@ -2463,7 +2466,7 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,if (ops->vidioc_try_ext_ctrls ==NULL )return -ENOTTY ;return check_ext_ctrls (p,VIDIOC_TRY_EXT_CTRLS ) ? - ops->vidioc_try_ext_ctrls (file,NULL , p) : -EINVAL ; + ops->vidioc_try_ext_ctrls (file, state, p) : -EINVAL ; }/* @@ -2475,8 +2478,8 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,* restore it afterwards. This way applications can use either buffer * type and drivers don't need to check for both. */ -static int v4l_g_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_g_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;@@ -2486,13 +2489,13 @@ static int v4l_g_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_g_selection (file,NULL , p); + ret = ops->vidioc_g_selection (file, state, p); p->type = old_type;return ret; } -static int v4l_s_selection (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +static int v4l_s_selection (const struct v4l2_ioctl_ops *ops,struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_selection *p = arg;u32 old_type = p->type;@@ -2502,13 +2505,13 @@ static int v4l_s_selection(const struct v4l2_ioctl_ops *ops, p->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ops->vidioc_s_selection (file,NULL , p); + ret = ops->vidioc_s_selection (file, state, p); p->type = old_type;return ret; }static int v4l_g_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;@@ -2529,7 +2532,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);/* copying results to old structure on success */ if (!ret)@@ -2538,7 +2541,7 @@ static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_s_crop (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_crop *p = arg;@@ -2559,11 +2562,11 @@ static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE ?V4L2_SEL_TGT_CROP :V4L2_SEL_TGT_COMPOSE ; -return v4l_s_selection (ops, file, &s); +return v4l_s_selection (ops, file, state, &s); }static int v4l_cropcap (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_cropcap *p = arg;@@ -2587,7 +2590,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,return -ENOTTY ;if (ops->vidioc_g_pixelaspect) - ret = ops->vidioc_g_pixelaspect (file,NULL , s.type, + ret = ops->vidioc_g_pixelaspect (file, state, s.type, &p->pixelaspect);/* @@ -2609,7 +2612,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, s.target = s.target ==V4L2_SEL_TGT_COMPOSE_BOUNDS ?V4L2_SEL_TGT_CROP_BOUNDS :V4L2_SEL_TGT_COMPOSE_BOUNDS ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->bounds = s.r;@@ -2620,7 +2623,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file,else s.target =V4L2_SEL_TGT_CROP_DEFAULT ; - ret =v4l_g_selection (ops, file, &s); + ret =v4l_g_selection (ops, file, state, &s);if (ret)return ret; p->defrect = s.r;@@ -2629,7 +2632,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_log_status (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);int ret;@@ -2637,7 +2640,7 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file,if (vfd->v4l2_dev)pr_info ("%s: ================= START STATUS =================\n" , vfd->v4l2_dev->name); - ret = ops->vidioc_log_status (file,NULL ); + ret = ops->vidioc_log_status (file, state);if (vfd->v4l2_dev)pr_info ("%s: ================== END STATUS ==================\n" , vfd->v4l2_dev->name);@@ -2645,7 +2648,8 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_dbg_g_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct v4l2_dbg_register *p = arg;@@ -2665,7 +2669,7 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_g_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_g_register (file,NULL , p); +return ops->vidioc_g_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;@@ -2673,7 +2677,8 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_s_register (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG const struct v4l2_dbg_register *p = arg;@@ -2693,7 +2698,7 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }if (ops->vidioc_s_register && p->match.type ==V4L2_CHIP_MATCH_BRIDGE && (ops->vidioc_g_chip_info || p->match.addr ==0 )) -return ops->vidioc_s_register (file,NULL , p); +return ops->vidioc_s_register (file, state, p);return -EINVAL ;#else return -ENOTTY ;@@ -2701,7 +2706,8 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, }static int v4l_dbg_g_chip_info (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {#ifdef CONFIG_VIDEO_ADV_DEBUG struct video_device *vfd =video_devdata (file);@@ -2717,7 +2723,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, p->flags |=V4L2_CHIP_FL_READABLE ;strscpy (p->name, vfd->v4l2_dev->name,sizeof (p->name));if (ops->vidioc_g_chip_info) -return ops->vidioc_g_chip_info (file,NULL , arg); +return ops->vidioc_g_chip_info (file, state, arg);if (p->match.addr)return -EINVAL ;return 0 ;@@ -2744,7 +2750,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, }static int v4l_dqevent (const struct v4l2_ioctl_ops *ops,struct file *file, -void *arg) +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2752,7 +2758,8 @@ static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, struct file *file, }static int v4l_subscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2760,7 +2767,8 @@ static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_unsubscribe_event (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -2768,7 +2776,8 @@ static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, }static int v4l_g_sliced_vbi_cap (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct v4l2_sliced_vbi_cap *p = arg;int ret =check_fmt (file, p->type);@@ -2779,11 +2788,12 @@ static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops,/* Clear up to type, everything after type is zeroed already */ memset (p,0 , offsetof(struct v4l2_sliced_vbi_cap , type)); -return ops->vidioc_g_sliced_vbi_cap (file,NULL , p); +return ops->vidioc_g_sliced_vbi_cap (file, state, p); }static int v4l_enum_freq_bands (const struct v4l2_ioctl_ops *ops, -struct file *file,void *arg) +struct file *file, +struct video_device_state *state,void *arg) {struct video_device *vfd =video_devdata (file);struct v4l2_frequency_band *p = arg;@@ -2801,7 +2811,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ; }if (ops->vidioc_enum_freq_bands) { - err = ops->vidioc_enum_freq_bands (file,NULL , p); + err = ops->vidioc_enum_freq_bands (file, state, p);if (err != -ENOTTY )return err; }@@ -2813,7 +2823,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,if (p->index)return -EINVAL ; - err = ops->vidioc_g_tuner (file,NULL , &t); + err = ops->vidioc_g_tuner (file, state, &t);if (err)return err; p->capability = t.capability |V4L2_TUNER_CAP_FREQ_BANDS ;@@ -2832,7 +2842,7 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,return -EINVAL ;if (p->index)return -EINVAL ; - err = ops->vidioc_g_modulator (file,NULL , &m); + err = ops->vidioc_g_modulator (file, state, &m);if (err)return err; p->capability = m.capability |V4L2_TUNER_CAP_FREQ_BANDS ;@@ -2849,7 +2859,7 @@ struct v4l2_ioctl_info {u32 flags;const char *const name;int (*func)(const struct v4l2_ioctl_ops *ops,struct file *file, -void *p); +struct video_device_state *state,void *p);void (*debug)(const void *arg,bool write_only); };@@ -2870,7 +2880,9 @@ struct v4l2_ioctl_info {#define DEFINE_V4L_STUB_FUNC (_vidioc) \ static int v4l_stub_ ## _vidioc( \ const struct v4l2_ioctl_ops *ops, \ - struct file *file, void *p) \ + struct file *file, \ + struct video_device_state *state, \ + void *p) \ { \ return ops->vidioc_ ## _vidioc(file, NULL, p); \ }@@ -3126,7 +3138,7 @@ static long __video_do_ioctl(struct file *file, write_only =_IOC_DIR (cmd) == _IOC_WRITE;if (info != &default_info) { - ret = info->func (ops, file, arg); + ret = info->func (ops, file,NULL , arg); }else if (!ops->vidioc_default) { ret = -ENOTTY ; }else {
PATCH v2 6/10 media: Replace void * with video_device_state * in all driver ioctl implementations
In reply to Jai LuthraReplace the opaque (and unused) pointer with a pointer to the video device state in all V4L2 driver ioctl implementations.
Most changes were automated using Coccinelle semantic patches for both drivers and framework helpers:
@ops@
identifier ops;
identifier vidioc_op;
identifier fn;
@@
struct v4l2_ioctl_ops ops = {
...,
.vidioc_op = fn,
...,
};// Rule 1 (like vidioc_log_status)
@depends on ops@
identifier ops.fn;
identifier filep;
identifier priv;
@@
int fn(struct file *filep,
- void *priv)
+ struct video_device_state *state)
{
<...
- priv
+ state
...>
}// Rule 2 (most ioctls)
@depends on ops@
identifier ops.fn;
identifier filep;
identifier priv;
identifier arg;
type T;
@@
int fn(struct file *filep,
- void *priv,
+ struct video_device_state *state,
T arg)
{
<...
- priv
+ state
...>
}// Rule 3 (like vidioc_g_pixelaspect)
@depends on ops@
identifier ops.fn;
identifier filep;
identifier priv;
identifier buf_type;
identifier arg;
type T1, T2;
@@
int fn(struct file *filep,
- void *priv,
+ struct video_device_state *state,
T1 buf_type, T2 *arg)
{
<...
- priv
+ state
...>
}// Rule 4 (like vidioc_default)
@depends on ops@
identifier ops.fn;
identifier filep;
identifier priv;
identifier valid_prio;
identifier cmd;
identifier arg;
@@
long fn(struct file *filep,
- void *priv,
+ struct video_device_state *state,
bool valid_prio, unsigned int cmd, void *arg)
{
<...
- priv
+ state
...>
}Function signature updates in headers and edge cases where drivers call ioctl implementations internally were handled manually.
--
Cc: Dmitry Torokhov <[email protected]>
Cc: Nick Dyer <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Tomasz Figa <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Matt Ranostay <[email protected]>
Cc: Andy Walls <[email protected]>
Cc: Yong Zhi <[email protected]>
Cc: Sakari Ailus <[email protected]>
Cc: Bingbu Cao <[email protected]>
Cc: Dan Scally <[email protected]>
Cc: Tianshu Qiu <[email protected]>
Cc: Martin Tuma <[email protected]>
Cc: Bluecherry Maintainers <[email protected]>
Cc: Andrey Utkin <[email protected]>
Cc: Ismael Luceno <[email protected]>
Cc: Ezequiel Garcia <[email protected]>
Cc: Corentin Labbe <[email protected]>
Cc: Michael Tretter <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Keke Li <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Kevin Hilman <[email protected]>
Cc: Jerome Brunet <[email protected]>
Cc: Martin Blumenstingl <[email protected]>
Cc: Ming Qian <[email protected]>
Cc: Zhou Peng <[email protected]>
Cc: Eddie James <[email protected]>
Cc: Joel Stanley <[email protected]>
Cc: Andrew Jeffery <[email protected]>
Cc: Eugen Hristev <[email protected]>
Cc: Nicolas Ferre <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Claudiu Beznea <[email protected]>
Cc: Raspberry Pi Kernel Maintenance <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Broadcom internal kernel review list <[email protected]>
Cc: Ray Jui <[email protected]>
Cc: Scott Branden <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Nas Chung <[email protected]>
Cc: Jackson Lee <[email protected]>
Cc: Devarsh Thakkar <[email protected]>
Cc: Bin Liu <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: AngeloGioacchino Del Regno <[email protected]>
Cc: Minghsiu Tsai <[email protected]>
Cc: Houlong Wei <[email protected]>
Cc: Andrew-CT Chen <[email protected]>
Cc: Tiffany Lin <[email protected]>
Cc: Yunfei Dong <[email protected]>
Cc: Joseph Liu <[email protected]>
Cc: Marvin Lin <[email protected]>
Cc: Dmitry Osipenko <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Jonathan Hunter <[email protected]>
Cc: Xavier Roumegue <[email protected]>
Cc: Mirela Rabulea <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Rui Miguel Silva <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Martin Kepplinger <[email protected]>
Cc: Purism Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Todor Tomov <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Vladimir Zapolskiy <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: Dikshita Agarwal <[email protected]>
Cc: Abhinav Kumar <[email protected]>
Cc: Jacopo Mondi <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
Cc: "Niklas Söderlund" <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Fabrizio Castro <[email protected]>
Cc: Kieran Bingham <[email protected]>
Cc: Nikita Yushchenko <[email protected]>
Cc: Jacob Chen <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: Dafna Hirschfeld <[email protected]>
Cc: Detlev Casanova <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: "Łukasz Stelmach" <[email protected]>
Cc: Andrzej Pietrasiewicz <[email protected]>
Cc: Jacek Anaszewski <[email protected]>
Cc: Andrzej Hajda <[email protected]>
Cc: Fabien Dessenne <[email protected]>
Cc: Hugues Fruchet <[email protected]>
Cc: Jean-Christophe Trotin <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Alain Volmat <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Chen-Yu Tsai <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Samuel Holland <[email protected]>
Cc: Yong Deng <[email protected]>
Cc: Paul Kocialkowski <[email protected]>
Cc: Shreeya Patel <[email protected]>
Cc: "Lad, Prabhakar" <[email protected]>
Cc: Yemike Abhilash Chandra <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: Nicolas Dufresne <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Alexey Klimov <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Daniel Almeida <[email protected]>
Cc: Michael Krufky <[email protected]>
Cc: Mike Isely <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Steve Longerbeam <[email protected]>
Cc: Jack Zhu <[email protected]>
Cc: Changhuang Liang <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>
Cc: Luca Ceresoli <[email protected]>
Cc: Parthiban Veerasooran <[email protected]>
Cc: Christian Gromm <[email protected]>
Cc: "Uwe Kleine-König" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Plamen Atanasov <[email protected]>
Cc: Sean Young <[email protected]>
Cc: Ariel Otilibili <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: Jiasheng Jiang <[email protected]>
Cc: Lad Prabhakar <[email protected]>
Cc: Tommaso Merciai <[email protected]>
Cc: Biju Das <[email protected]>
Cc: Daniel Scally <[email protected]>
Cc: Matthew Majewski <[email protected]>
Cc: Yunseong Kim <[email protected]>
Cc: Chen Ni <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Fabio Luongo <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Yang Yingliang <[email protected]>
Cc: Ludwig Disterhof <[email protected]>
Cc: Ma Ke <[email protected]>
Cc: "Everest K.C." <[email protected]>
Cc: Stefan Wahren <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: Michael Grzeschik <[email protected]>
Cc: Akash Kumar <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/input/rmi4/rmi_f54.c | 22 +- drivers/input/touchscreen/atmel_mxt_ts.c | 23 +- drivers/input/touchscreen/sur40.c | 35 ++- .../extron-da-hd-4k-plus/extron-da-hd-4k-plus.c | 34 ++- drivers/media/common/saa7146/saa7146_video.c | 37 +++- drivers/media/common/videobuf2/videobuf2-v4l2.c | 30 ++- drivers/media/dvb-frontends/rtl2832_sdr.c | 38 ++-- drivers/media/i2c/video-i2c.c | 39 ++-- drivers/media/pci/bt8xx/bttv-driver.c | 84 +++++--- drivers/media/pci/bt8xx/bttv-vbi.c | 11 +- drivers/media/pci/bt8xx/bttvp.h | 9 +- drivers/media/pci/cobalt/cobalt-v4l2.c | 98 +++++---- drivers/media/pci/cx18/cx18-driver.c | 9 +- drivers/media/pci/cx18/cx18-ioctl.c | 114 ++++++---- drivers/media/pci/cx18/cx18-ioctl.h | 9 +- drivers/media/pci/cx23885/cx23885-417.c | 53 +++-- drivers/media/pci/cx23885/cx23885-ioctl.c | 8 +- drivers/media/pci/cx23885/cx23885-ioctl.h | 9 +- drivers/media/pci/cx23885/cx23885-vbi.c | 5 +- drivers/media/pci/cx23885/cx23885-video.c | 82 ++++--- drivers/media/pci/cx23885/cx23885.h | 4 +- drivers/media/pci/cx25821/cx25821-video.c | 57 +++-- drivers/media/pci/cx88/cx88-blackbird.c | 47 ++-- drivers/media/pci/cx88/cx88-vbi.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 56 +++-- drivers/media/pci/cx88/cx88.h | 2 +- drivers/media/pci/dt3155/dt3155.c | 25 ++- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 29 ++- drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 41 ++-- drivers/media/pci/ivtv/ivtv-driver.c | 8 +- drivers/media/pci/ivtv/ivtv-ioctl.c | 225 +++++++++++++------ drivers/media/pci/ivtv/ivtv-ioctl.h | 6 +- drivers/media/pci/mgb4/mgb4_vin.c | 55 +++-- drivers/media/pci/mgb4/mgb4_vout.c | 49 +++-- drivers/media/pci/saa7134/saa7134-empress.c | 12 +- drivers/media/pci/saa7134/saa7134-video.c | 96 +++++---- drivers/media/pci/saa7134/saa7134.h | 38 ++-- drivers/media/pci/saa7146/hexium_gemini.c | 10 +- drivers/media/pci/saa7146/hexium_orion.c | 10 +- drivers/media/pci/saa7146/mxb.c | 46 ++-- drivers/media/pci/saa7164/saa7164-encoder.c | 39 ++-- drivers/media/pci/saa7164/saa7164-vbi.c | 27 ++- drivers/media/pci/saa7164/saa7164.h | 9 +- drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 46 ++-- drivers/media/pci/solo6x10/solo6x10-v4l2.c | 32 ++- drivers/media/pci/ttpci/budget-av.c | 10 +- drivers/media/pci/tw5864/tw5864-video.c | 49 +++-- drivers/media/pci/tw68/tw68-video.c | 43 ++-- drivers/media/pci/tw686x/tw686x-video.c | 53 +++-- drivers/media/pci/zoran/zoran_driver.c | 44 ++-- drivers/media/platform/allegro-dvt/allegro-core.c | 49 +++-- .../media/platform/amlogic/c3/isp/c3-isp-capture.c | 18 +- .../media/platform/amlogic/c3/isp/c3-isp-params.c | 9 +- .../media/platform/amlogic/c3/isp/c3-isp-stats.c | 9 +- drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 36 +++- drivers/media/platform/amphion/vdec.c | 30 ++- drivers/media/platform/amphion/venc.c | 49 +++-- drivers/media/platform/aspeed/aspeed-video.c | 50 +++-- drivers/media/platform/atmel/atmel-isi.c | 36 ++-- drivers/media/platform/broadcom/bcm2835-unicam.c | 33 ++- .../media/platform/chips-media/coda/coda-common.c | 69 +++--- .../platform/chips-media/wave5/wave5-helper.c | 2 +- .../platform/chips-media/wave5/wave5-helper.h | 3 +- .../platform/chips-media/wave5/wave5-vpu-dec.c | 54 +++-- .../platform/chips-media/wave5/wave5-vpu-enc.c | 62 ++++-- .../media/platform/imagination/e5010-jpeg-enc.c | 34 ++- drivers/media/platform/intel/pxa_camera.c | 34 ++- drivers/media/platform/m2m-deinterlace.c | 34 +-- drivers/media/platform/marvell/mcam-core.c | 52 +++-- .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 44 ++-- drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 34 +-- .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 25 ++- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 52 +++-- .../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 50 +++-- .../media/platform/microchip/microchip-isc-base.c | 33 ++- drivers/media/platform/nuvoton/npcm-video.c | 43 ++-- drivers/media/platform/nvidia/tegra-vde/v4l2.c | 38 ++-- drivers/media/platform/nxp/dw100/dw100.c | 35 +-- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 52 +++-- drivers/media/platform/nxp/imx-pxp.c | 34 +-- drivers/media/platform/nxp/imx7-media-csi.c | 21 +- drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 15 +- .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 18 +- drivers/media/platform/nxp/mx2_emmaprp.c | 31 ++- drivers/media/platform/qcom/camss/camss-video.c | 27 ++- drivers/media/platform/qcom/iris/iris_vidc.c | 48 +++-- drivers/media/platform/qcom/venus/vdec.c | 29 ++- drivers/media/platform/qcom/venus/venc.c | 38 ++-- .../media/platform/raspberrypi/pisp_be/pisp_be.c | 42 ++-- drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 40 ++-- .../media/platform/renesas/rcar-vin/rcar-v4l2.c | 21 +- drivers/media/platform/renesas/rcar_drif.c | 30 ++- drivers/media/platform/renesas/rcar_fdp1.c | 18 +- drivers/media/platform/renesas/rcar_jpu.c | 21 +- drivers/media/platform/renesas/renesas-ceu.c | 36 ++-- .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 18 +- drivers/media/platform/renesas/sh_vou.c | 41 ++-- drivers/media/platform/renesas/vsp1/vsp1_histo.c | 9 +- drivers/media/platform/renesas/vsp1/vsp1_video.c | 18 +- drivers/media/platform/rockchip/rga/rga.c | 24 ++- .../platform/rockchip/rkisp1/rkisp1-capture.c | 18 +- .../media/platform/rockchip/rkisp1/rkisp1-params.c | 15 +- .../media/platform/rockchip/rkisp1/rkisp1-stats.c | 9 +- drivers/media/platform/rockchip/rkvdec/rkvdec.c | 34 +-- .../media/platform/samsung/exynos-gsc/gsc-m2m.c | 44 ++-- .../platform/samsung/exynos4-is/fimc-capture.c | 45 ++-- .../platform/samsung/exynos4-is/fimc-isp-video.c | 32 +-- .../media/platform/samsung/exynos4-is/fimc-lite.c | 36 ++-- .../media/platform/samsung/exynos4-is/fimc-m2m.c | 21 +- .../platform/samsung/s3c-camif/camif-capture.c | 54 +++-- drivers/media/platform/samsung/s5p-g2d/g2d.c | 26 ++- .../media/platform/samsung/s5p-jpeg/jpeg-core.c | 34 +-- .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 48 +++-- .../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 51 +++-- drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 26 ++- drivers/media/platform/st/sti/delta/delta-v4l2.c | 44 ++-- drivers/media/platform/st/sti/hva/hva-v4l2.c | 46 ++-- drivers/media/platform/st/stm32/dma2d/dma2d.c | 18 +- drivers/media/platform/st/stm32/stm32-dcmi.c | 42 ++-- .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 20 +- .../media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 25 ++- .../platform/sunxi/sun6i-csi/sun6i_csi_capture.c | 24 ++- drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 31 ++- .../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 34 +-- .../media/platform/synopsys/hdmirx/snps_hdmirx.c | 47 ++-- drivers/media/platform/ti/am437x/am437x-vpfe.c | 52 +++-- drivers/media/platform/ti/cal/cal-video.c | 54 +++-- drivers/media/platform/ti/davinci/vpif_capture.c | 94 ++++---- drivers/media/platform/ti/davinci/vpif_display.c | 58 +++-- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 20 +- drivers/media/platform/ti/omap/omap_vout.c | 49 +++-- drivers/media/platform/ti/omap3isp/ispvideo.c | 53 +++-- drivers/media/platform/ti/vpe/vpe.c | 25 ++- drivers/media/platform/verisilicon/hantro_v4l2.c | 47 ++-- drivers/media/platform/via/via-camera.c | 42 ++-- drivers/media/platform/xilinx/xilinx-dma.c | 15 +- drivers/media/radio/dsbr100.c | 15 +- drivers/media/radio/radio-cadet.c | 18 +- drivers/media/radio/radio-isa.c | 18 +- drivers/media/radio/radio-keene.c | 15 +- drivers/media/radio/radio-ma901.c | 15 +- drivers/media/radio/radio-miropcm20.c | 15 +- drivers/media/radio/radio-mr800.c | 18 +- drivers/media/radio/radio-raremono.c | 19 +- drivers/media/radio/radio-sf16fmi.c | 15 +- drivers/media/radio/radio-si476x.c | 28 ++- drivers/media/radio/radio-tea5764.c | 15 +- drivers/media/radio/radio-tea5777.c | 21 +- drivers/media/radio/radio-timb.c | 26 ++- drivers/media/radio/si470x/radio-si470x-common.c | 25 ++- drivers/media/radio/si4713/radio-platform-si4713.c | 18 +- drivers/media/radio/si4713/radio-usb-si4713.c | 15 +- drivers/media/radio/tea575x.c | 21 +- drivers/media/test-drivers/vicodec/vicodec-core.c | 54 +++-- drivers/media/test-drivers/vim2m.c | 56 +++-- drivers/media/test-drivers/vimc/vimc-capture.c | 20 +- drivers/media/test-drivers/visl/visl-video.c | 34 +-- drivers/media/test-drivers/vivid/vivid-core.c | 203 ++++++++++-------- drivers/media/test-drivers/vivid/vivid-meta-cap.c | 6 +- drivers/media/test-drivers/vivid/vivid-meta-cap.h | 6 +- drivers/media/test-drivers/vivid/vivid-meta-out.c | 6 +- drivers/media/test-drivers/vivid/vivid-meta-out.h | 9 +- drivers/media/test-drivers/vivid/vivid-radio-rx.c | 16 +- drivers/media/test-drivers/vivid/vivid-radio-rx.h | 16 +- drivers/media/test-drivers/vivid/vivid-radio-tx.c | 6 +- drivers/media/test-drivers/vivid/vivid-radio-tx.h | 6 +- drivers/media/test-drivers/vivid/vivid-sdr-cap.c | 30 ++- drivers/media/test-drivers/vivid/vivid-sdr-cap.h | 30 ++- drivers/media/test-drivers/vivid/vivid-touch-cap.c | 22 +- drivers/media/test-drivers/vivid/vivid-touch-cap.h | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-cap.c | 26 ++- drivers/media/test-drivers/vivid/vivid-vbi-cap.h | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-out.c | 22 +- drivers/media/test-drivers/vivid/vivid-vbi-out.h | 18 +- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 114 ++++++---- drivers/media/test-drivers/vivid/vivid-vid-cap.h | 117 +++++++--- .../media/test-drivers/vivid/vivid-vid-common.c | 24 ++- .../media/test-drivers/vivid/vivid-vid-common.h | 34 +-- drivers/media/test-drivers/vivid/vivid-vid-out.c | 122 ++++++----- drivers/media/test-drivers/vivid/vivid-vid-out.h | 95 +++++--- drivers/media/usb/airspy/airspy.c | 37 ++-- drivers/media/usb/au0828/au0828-video.c | 74 ++++--- drivers/media/usb/cx231xx/cx231xx-417.c | 28 ++- drivers/media/usb/cx231xx/cx231xx-video.c | 79 ++++--- drivers/media/usb/cx231xx/cx231xx.h | 39 ++-- drivers/media/usb/dvb-usb/cxusb-analog.c | 48 +++-- drivers/media/usb/em28xx/em28xx-video.c | 87 +++++--- drivers/media/usb/go7007/go7007-v4l2.c | 75 ++++--- drivers/media/usb/gspca/gspca.c | 51 +++-- drivers/media/usb/hackrf/hackrf.c | 39 ++-- drivers/media/usb/hdpvr/hdpvr-video.c | 60 ++++-- drivers/media/usb/msi2500/msi2500.c | 31 ++- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 98 ++++++--- drivers/media/usb/pwc/pwc-v4l.c | 44 ++-- drivers/media/usb/s2255/s2255drv.c | 55 +++-- drivers/media/usb/stk1160/stk1160-v4l.c | 40 ++-- drivers/media/usb/usbtv/usbtv-video.c | 24 ++- drivers/media/usb/uvc/uvc_metadata.c | 17 +- drivers/media/usb/uvc/uvc_v4l2.c | 59 +++-- drivers/media/v4l2-core/v4l2-ctrls-api.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 4 +- drivers/media/v4l2-core/v4l2-mem2mem.c | 56 +++-- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 72 ++++--- drivers/staging/media/av7110/av7110_v4l.c | 60 ++++-- .../media/deprecated/atmel/atmel-isc-base.c | 33 ++- drivers/staging/media/imx/imx-media-capture.c | 53 +++-- drivers/staging/media/imx/imx-media-csc-scaler.c | 23 +- drivers/staging/media/ipu3/ipu3-v4l2.c | 29 ++- drivers/staging/media/ipu7/ipu7-isys-video.c | 30 ++- drivers/staging/media/meson/vdec/vdec.c | 26 ++- drivers/staging/media/starfive/camss/stf-video.c | 18 +- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 29 ++- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 24 ++- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 9 +- drivers/staging/media/tegra-video/vi.c | 68 ++++-- drivers/staging/most/video/video.c | 39 ++-- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 58 +++-- drivers/usb/gadget/function/uvc_v4l2.c | 50 +++-- include/media/v4l2-ctrls.h | 5 +- include/media/v4l2-dev.h | 2 +- include/media/v4l2-ioctl.h | 238 +++++++++++---------- include/media/v4l2-mem2mem.h | 48 +++-- include/media/videobuf2-v4l2.h | 33 +-- 223 files changed, 5392 insertions(+), 2955 deletions(-)
drivers/input/rmi4/rmi_f54.c +15 -7
@@ -383,7 +383,8 @@ static const struct vb2_queue rmi_f54_queue = { .timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, }; -static int rmi_f54_vidioc_querycap (struct file *file,void *priv, +static int rmi_f54_vidioc_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {struct f54_data *f54 =video_drvdata (file);
@@ -396,7 +397,8 @@ static int rmi_f54_vidioc_querycap(struct file *file, void *priv,return 0 ; } -static int rmi_f54_vidioc_enum_input (struct file *file,void *priv, +static int rmi_f54_vidioc_enum_input (struct file *file, +struct video_device_state *state,struct v4l2_input *i) {struct f54_data *f54 =video_drvdata (file);
@@ -442,12 +444,15 @@ static int rmi_f54_set_input(struct f54_data *f54, unsigned int i)return 0 ; } -static int rmi_f54_vidioc_s_input (struct file *file,void *priv,unsigned int i) +static int rmi_f54_vidioc_s_input (struct file *file, +struct video_device_state *state, +unsigned int i) {return rmi_f54_set_input (video_drvdata (file), i); } -static int rmi_f54_vidioc_g_input (struct file *file,void *priv, +static int rmi_f54_vidioc_g_input (struct file *file, +struct video_device_state *state,unsigned int *i) {struct f54_data *f54 =video_drvdata (file);
@@ -457,7 +462,8 @@ static int rmi_f54_vidioc_g_input(struct file *file, void *priv,return 0 ; } -static int rmi_f54_vidioc_fmt (struct file *file,void *priv, +static int rmi_f54_vidioc_fmt (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct f54_data *f54 =video_drvdata (file);
@@ -467,7 +473,8 @@ static int rmi_f54_vidioc_fmt(struct file *file, void *priv,return 0 ; } -static int rmi_f54_vidioc_enum_fmt (struct file *file,void *priv, +static int rmi_f54_vidioc_enum_fmt (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *fmt) {struct f54_data *f54 =video_drvdata (file);
@@ -483,7 +490,8 @@ static int rmi_f54_vidioc_enum_fmt(struct file *file, void *priv,return 0 ; } -static int rmi_f54_vidioc_g_parm (struct file *file,void *fh, +static int rmi_f54_vidioc_g_parm (struct file *file, +struct video_device_state *state,struct v4l2_streamparm *a) {if (a->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )
drivers/input/touchscreen/atmel_mxt_ts.c +16 -7
@@ -2547,7 +2547,8 @@ static const struct vb2_queue mxt_queue = { .min_queued_buffers = 1, }; -static int mxt_vidioc_querycap (struct file *file,void *priv, +static int mxt_vidioc_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {struct mxt_data *data =video_drvdata (file);
@@ -2559,7 +2560,8 @@ static int mxt_vidioc_querycap(struct file *file, void *priv,return 0 ; } -static int mxt_vidioc_enum_input (struct file *file,void *priv, +static int mxt_vidioc_enum_input (struct file *file, +struct video_device_state *state,struct v4l2_input *i) {if (i->index >=MXT_V4L_INPUT_MAX )
@@ -2604,12 +2606,16 @@ static int mxt_set_input(struct mxt_data *data, unsigned int i)return 0 ; } -static int mxt_vidioc_s_input (struct file *file,void *priv,unsigned int i) +static int mxt_vidioc_s_input (struct file *file, +struct video_device_state *state, +unsigned int i) {return mxt_set_input (video_drvdata (file), i); } -static int mxt_vidioc_g_input (struct file *file,void *priv,unsigned int *i) +static int mxt_vidioc_g_input (struct file *file, +struct video_device_state *state, +unsigned int *i) {struct mxt_data *data =video_drvdata (file);
@@ -2618,7 +2624,8 @@ static int mxt_vidioc_g_input(struct file *file, void *priv, unsigned int *i)return 0 ; } -static int mxt_vidioc_fmt (struct file *file,void *priv,struct v4l2_format *f) +static int mxt_vidioc_fmt (struct file *file,struct video_device_state *state, +struct v4l2_format *f) {struct mxt_data *data =video_drvdata (file);
@@ -2628,7 +2635,8 @@ static int mxt_vidioc_fmt(struct file *file, void *priv, struct v4l2_format *f)return 0 ; } -static int mxt_vidioc_enum_fmt (struct file *file,void *priv, +static int mxt_vidioc_enum_fmt (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *fmt) {if (fmt->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )
@@ -2650,7 +2658,8 @@ static int mxt_vidioc_enum_fmt(struct file *file, void *priv,return 0 ; } -static int mxt_vidioc_g_parm (struct file *file,void *fh, +static int mxt_vidioc_g_parm (struct file *file, +struct video_device_state *state,struct v4l2_streamparm *a) {if (a->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )
drivers/input/touchscreen/sur40.c +24 -11
@@ -935,7 +935,8 @@ static void sur40_stop_streaming(struct vb2_queue *vq) }/* V4L ioctl */ -static int sur40_vidioc_querycap (struct file *file,void *priv, +static int sur40_vidioc_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {struct sur40_state *sur40 =video_drvdata (file);
@@ -946,7 +947,8 @@ static int sur40_vidioc_querycap(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_enum_input (struct file *file,void *priv, +static int sur40_vidioc_enum_input (struct file *file, +struct video_device_state *state,struct v4l2_input *i) {if (i->index !=0 )
@@ -958,18 +960,23 @@ static int sur40_vidioc_enum_input(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_s_input (struct file *file,void *priv,unsigned int i) +static int sur40_vidioc_s_input (struct file *file, +struct video_device_state *state, +unsigned int i) {return (i ==0 ) ?0 : -EINVAL ; } -static int sur40_vidioc_g_input (struct file *file,void *priv,unsigned int *i) +static int sur40_vidioc_g_input (struct file *file, +struct video_device_state *state, +unsigned int *i) { *i =0 ;return 0 ; } -static int sur40_vidioc_try_fmt (struct file *file,void *priv, +static int sur40_vidioc_try_fmt (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {switch (f->fmt.pix.pixelformat) {
@@ -985,7 +992,8 @@ static int sur40_vidioc_try_fmt(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_s_fmt (struct file *file,void *priv, +static int sur40_vidioc_s_fmt (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct sur40_state *sur40 =video_drvdata (file);
@@ -1004,7 +1012,8 @@ static int sur40_vidioc_s_fmt(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_g_fmt (struct file *file,void *priv, +static int sur40_vidioc_g_fmt (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct sur40_state *sur40 =video_drvdata (file);
@@ -1038,7 +1047,8 @@ static int sur40_s_ctrl(struct v4l2_ctrl *ctrl)return 0 ; } -static int sur40_ioctl_parm (struct file *file,void *priv, +static int sur40_ioctl_parm (struct file *file, +struct video_device_state *state,struct v4l2_streamparm *p) {if (p->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )
@@ -1051,7 +1061,8 @@ static int sur40_ioctl_parm(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_enum_fmt (struct file *file,void *priv, +static int sur40_vidioc_enum_fmt (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *f) {if (f->index >=ARRAY_SIZE (sur40_pix_format))
@@ -1062,7 +1073,8 @@ static int sur40_vidioc_enum_fmt(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_enum_framesizes (struct file *file,void *priv, +static int sur40_vidioc_enum_framesizes (struct file *file, +struct video_device_state *state,struct v4l2_frmsizeenum *f) {struct sur40_state *sur40 =video_drvdata (file);
@@ -1077,7 +1089,8 @@ static int sur40_vidioc_enum_framesizes(struct file *file, void *priv,return 0 ; } -static int sur40_vidioc_enum_frameintervals (struct file *file,void *priv, +static int sur40_vidioc_enum_frameintervals (struct file *file, +struct video_device_state *state,struct v4l2_frmivalenum *f) {struct sur40_state *sur40 =video_drvdata (file);
drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c +23 -11
@@ -1195,7 +1195,8 @@ static const struct cec_adap_ops extron_cec_adap_ops = { .received = extron_received, }; -static int extron_querycap (struct file *file,void *priv, +static int extron_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {struct extron_port *port =video_drvdata (file);
@@ -1206,7 +1207,9 @@ static int extron_querycap(struct file *file, void *priv,return 0 ; } -static int extron_enum_input (struct file *file,void *priv,struct v4l2_input *inp) +static int extron_enum_input (struct file *file, +struct video_device_state *state, +struct v4l2_input *inp) {struct extron_port *port =video_drvdata (file);
@@ -1219,18 +1222,22 @@ static int extron_enum_input(struct file *file, void *priv, struct v4l2_input *ireturn 0 ; } -static int extron_g_input (struct file *file,void *priv,unsigned int *i) +static int extron_g_input (struct file *file,struct video_device_state *state, +unsigned int *i) { *i =0 ;return 0 ; } -static int extron_s_input (struct file *file,void *priv,unsigned int i) +static int extron_s_input (struct file *file,struct video_device_state *state, +unsigned int i) {return i ? -EINVAL :0 ; } -static int extron_enum_output (struct file *file,void *priv,struct v4l2_output *out) +static int extron_enum_output (struct file *file, +struct video_device_state *state, +struct v4l2_output *out) {struct extron_port *port =video_drvdata (file);
@@ -1241,18 +1248,21 @@ static int extron_enum_output(struct file *file, void *priv, struct v4l2_outputreturn 0 ; } -static int extron_g_output (struct file *file,void *priv,unsigned int *o) +static int extron_g_output (struct file *file, +struct video_device_state *state,unsigned int *o) { *o =0 ;return 0 ; } -static int extron_s_output (struct file *file,void *priv,unsigned int o) +static int extron_s_output (struct file *file, +struct video_device_state *state,unsigned int o) {return o ? -EINVAL :0 ; } -static int extron_g_edid (struct file *file,void *priv, +static int extron_g_edid (struct file *file, +struct video_device_state *state,struct v4l2_edid *edid) {struct extron_port *port =video_drvdata (file);
@@ -1280,7 +1290,8 @@ static int extron_g_edid(struct file *file, void *priv,return 0 ; } -static int extron_s_edid (struct file *file,void *priv,struct v4l2_edid *edid) +static int extron_s_edid (struct file *file,struct video_device_state *state, +struct v4l2_edid *edid) {struct extron_port *port =video_drvdata (file);
@@ -1305,12 +1316,13 @@ static int extron_s_edid(struct file *file, void *priv, struct v4l2_edid *edid)return extron_write_edid (port, edid->edid, edid->blocks); } -static int extron_log_status (struct file *file,void *priv) +static int extron_log_status (struct file *file, +struct video_device_state *state) {struct extron_port *port =video_drvdata (file);extron_adap_status (port->adap,NULL ); -return v4l2_ctrl_log_status (file, priv); +return v4l2_ctrl_log_status (file, state); }static const struct v4l2_ioctl_ops extron_ioctl_ops = {
drivers/media/common/saa7146/saa7146_video.c +26 -11
@@ -251,7 +251,9 @@ static void video_end(struct saa7146_dev *dev)saa7146_res_free (dev, resource); } -static int vidioc_querycap (struct file *file,void *fh,struct v4l2_capability *cap) +static int vidioc_querycap (struct file *file, +struct video_device_state *state, +struct v4l2_capability *cap) {struct saa7146_dev *dev =video_drvdata (file);
@@ -264,7 +266,9 @@ static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *return 0 ; } -static int vidioc_enum_fmt_vid_cap (struct file *file,void *fh,struct v4l2_fmtdesc *f) +static int vidioc_enum_fmt_vid_cap (struct file *file, +struct video_device_state *state, +struct v4l2_fmtdesc *f) {if (f->index >=ARRAY_SIZE (formats))return -EINVAL ;
@@ -323,7 +327,8 @@ int saa7146_s_ctrl(struct v4l2_ctrl *ctrl)return 0 ; } -static int vidioc_g_parm (struct file *file,void *fh, +static int vidioc_g_parm (struct file *file, +struct video_device_state *state,struct v4l2_streamparm *parm) {struct saa7146_dev *dev =video_drvdata (file);
@@ -337,7 +342,9 @@ static int vidioc_g_parm(struct file *file, void *fh,return 0 ; } -static int vidioc_g_fmt_vid_cap (struct file *file,void *fh,struct v4l2_format *f) +static int vidioc_g_fmt_vid_cap (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
@@ -346,7 +353,9 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_formatreturn 0 ; } -static int vidioc_g_fmt_vbi_cap (struct file *file,void *fh,struct v4l2_format *f) +static int vidioc_g_fmt_vbi_cap (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
@@ -355,7 +364,9 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_formatreturn 0 ; } -static int vidioc_try_fmt_vid_cap (struct file *file,void *fh,struct v4l2_format *f) +static int vidioc_try_fmt_vid_cap (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
@@ -364,7 +375,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_formaint maxw, maxh;int calc_bpl; -DEB_EE ("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n" , dev, fh); +DEB_EE ("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n" , dev, state); fmt =saa7146_format_by_fourcc (dev, f->fmt.pix.pixelformat);if (NULL == fmt)
@@ -417,7 +428,9 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_formareturn 0 ; } -static int vidioc_s_fmt_vid_cap (struct file *file,void *fh,struct v4l2_format *f) +static int vidioc_s_fmt_vid_cap (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
@@ -428,7 +441,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_formatDEB_EE ("streaming capture is active\n" );return -EBUSY ; } - err =vidioc_try_fmt_vid_cap (file, fh, f); + err =vidioc_try_fmt_vid_cap (file, state, f);if (0 != err)return err;switch (f->fmt.pix.field) {
@@ -445,7 +458,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_formatreturn 0 ; } -static int vidioc_g_std (struct file *file,void *fh,v4l2_std_id *norm) +static int vidioc_g_std (struct file *file,struct video_device_state *state, +v4l2_std_id *norm) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
@@ -454,7 +468,8 @@ static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)return 0 ; } -static int vidioc_s_std (struct file *file,void *fh,v4l2_std_id id) +static int vidioc_s_std (struct file *file,struct video_device_state *state, +v4l2_std_id id) {struct saa7146_dev *dev =video_drvdata (file);struct saa7146_vv *vv = dev->vv_data;
drivers/media/common/videobuf2/videobuf2-v4l2.c +20 -10
@@ -996,7 +996,8 @@ EXPORT_SYMBOL_GPL(vb2_poll);/* vb2 ioctl helpers */ -int vb2_ioctl_remove_bufs (struct file *file,void *priv, +int vb2_ioctl_remove_bufs (struct file *file, +struct video_device_state *state,struct v4l2_remove_buffers *d) {struct video_device *vdev =video_devdata (file);
@@ -1014,7 +1015,8 @@ int vb2_ioctl_remove_bufs(struct file *file, void *priv, }EXPORT_SYMBOL_GPL (vb2_ioctl_remove_bufs); -int vb2_ioctl_reqbufs (struct file *file,void *priv, +int vb2_ioctl_reqbufs (struct file *file, +struct video_device_state *state,struct v4l2_requestbuffers *p) {struct video_device *vdev =video_devdata (file);
@@ -1037,7 +1039,8 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv, }EXPORT_SYMBOL_GPL (vb2_ioctl_reqbufs); -int vb2_ioctl_create_bufs (struct file *file,void *priv, +int vb2_ioctl_create_bufs (struct file *file, +struct video_device_state *state,struct v4l2_create_buffers *p) {struct video_device *vdev =video_devdata (file);
@@ -1064,7 +1067,8 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv, }EXPORT_SYMBOL_GPL (vb2_ioctl_create_bufs); -int vb2_ioctl_prepare_buf (struct file *file,void *priv, +int vb2_ioctl_prepare_buf (struct file *file, +struct video_device_state *state,struct v4l2_buffer *p) {struct video_device *vdev =video_devdata (file);
@@ -1075,7 +1079,8 @@ int vb2_ioctl_prepare_buf(struct file *file, void *priv, }EXPORT_SYMBOL_GPL (vb2_ioctl_prepare_buf); -int vb2_ioctl_querybuf (struct file *file,void *priv,struct v4l2_buffer *p) +int vb2_ioctl_querybuf (struct file *file,struct video_device_state *state, +struct v4l2_buffer *p) {struct video_device *vdev =video_devdata (file);
@@ -1084,7 +1089,8 @@ int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) }EXPORT_SYMBOL_GPL (vb2_ioctl_querybuf); -int vb2_ioctl_qbuf (struct file *file,void *priv,struct v4l2_buffer *p) +int vb2_ioctl_qbuf (struct file *file,struct video_device_state *state, +struct v4l2_buffer *p) {struct video_device *vdev =video_devdata (file);
@@ -1094,7 +1100,8 @@ int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) }EXPORT_SYMBOL_GPL (vb2_ioctl_qbuf); -int vb2_ioctl_dqbuf (struct file *file,void *priv,struct v4l2_buffer *p) +int vb2_ioctl_dqbuf (struct file *file,struct video_device_state *state, +struct v4l2_buffer *p) {struct video_device *vdev =video_devdata (file);
@@ -1104,7 +1111,8 @@ int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) }EXPORT_SYMBOL_GPL (vb2_ioctl_dqbuf); -int vb2_ioctl_streamon (struct file *file,void *priv,enum v4l2_buf_type i) +int vb2_ioctl_streamon (struct file *file,struct video_device_state *state, +enum v4l2_buf_type i) {struct video_device *vdev =video_devdata (file);
@@ -1114,7 +1122,8 @@ int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i) }EXPORT_SYMBOL_GPL (vb2_ioctl_streamon); -int vb2_ioctl_streamoff (struct file *file,void *priv,enum v4l2_buf_type i) +int vb2_ioctl_streamoff (struct file *file,struct video_device_state *state, +enum v4l2_buf_type i) {struct video_device *vdev =video_devdata (file);
@@ -1124,7 +1133,8 @@ int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) }EXPORT_SYMBOL_GPL (vb2_ioctl_streamoff); -int vb2_ioctl_expbuf (struct file *file,void *priv,struct v4l2_exportbuffer *p) +int vb2_ioctl_expbuf (struct file *file,struct video_device_state *state, +struct v4l2_exportbuffer *p) {struct video_device *vdev =video_devdata (file);
drivers/media/dvb-frontends/rtl2832_sdr.c +20 -18
@@ -418,8 +418,8 @@ static void rtl2832_sdr_cleanup_queued_bufs(struct rtl2832_sdr_dev *dev)spin_unlock_irqrestore (&dev->queued_bufs_lock, flags); } -static int rtl2832_sdr_querycap (struct file *file,void *fh, -struct v4l2_capability *cap) +static int rtl2832_sdr_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -949,8 +949,8 @@ static const struct vb2_ops rtl2832_sdr_vb2_ops = { .stop_streaming = rtl2832_sdr_stop_streaming, }; -static int rtl2832_sdr_g_tuner (struct file *file,void *priv, -struct v4l2_tuner *v) +static int rtl2832_sdr_g_tuner (struct file *file, +struct video_device_state *state,struct v4l2_tuner *v) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -981,8 +981,8 @@ static int rtl2832_sdr_g_tuner(struct file *file, void *priv,return ret; } -static int rtl2832_sdr_s_tuner (struct file *file,void *priv, -const struct v4l2_tuner *v) +static int rtl2832_sdr_s_tuner (struct file *file, +struct video_device_state *state,const struct v4l2_tuner *v) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -1003,7 +1003,8 @@ static int rtl2832_sdr_s_tuner(struct file *file, void *priv,return ret; } -static int rtl2832_sdr_enum_freq_bands (struct file *file,void *priv, +static int rtl2832_sdr_enum_freq_bands (struct file *file, +struct video_device_state *state,struct v4l2_frequency_band *band) {struct rtl2832_sdr_dev *dev =video_drvdata (file);
@@ -1034,8 +1035,8 @@ static int rtl2832_sdr_enum_freq_bands(struct file *file, void *priv,return ret; } -static int rtl2832_sdr_g_frequency (struct file *file,void *priv, -struct v4l2_frequency *f) +static int rtl2832_sdr_g_frequency (struct file *file, +struct video_device_state *state,struct v4l2_frequency *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -1061,7 +1062,8 @@ static int rtl2832_sdr_g_frequency(struct file *file, void *priv,return ret; } -static int rtl2832_sdr_s_frequency (struct file *file,void *priv, +static int rtl2832_sdr_s_frequency (struct file *file, +struct video_device_state *state,const struct v4l2_frequency *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);
@@ -1105,8 +1107,8 @@ static int rtl2832_sdr_s_frequency(struct file *file, void *priv,return ret; } -static int rtl2832_sdr_enum_fmt_sdr_cap (struct file *file,void *priv, -struct v4l2_fmtdesc *f) +static int rtl2832_sdr_enum_fmt_sdr_cap (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -1121,8 +1123,8 @@ static int rtl2832_sdr_enum_fmt_sdr_cap(struct file *file, void *priv,return 0 ; } -static int rtl2832_sdr_g_fmt_sdr_cap (struct file *file,void *priv, -struct v4l2_format *f) +static int rtl2832_sdr_g_fmt_sdr_cap (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -1135,8 +1137,8 @@ static int rtl2832_sdr_g_fmt_sdr_cap(struct file *file, void *priv,return 0 ; } -static int rtl2832_sdr_s_fmt_sdr_cap (struct file *file,void *priv, -struct v4l2_format *f) +static int rtl2832_sdr_s_fmt_sdr_cap (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
@@ -1166,8 +1168,8 @@ static int rtl2832_sdr_s_fmt_sdr_cap(struct file *file, void *priv,return 0 ; } -static int rtl2832_sdr_try_fmt_sdr_cap (struct file *file,void *priv, -struct v4l2_format *f) +static int rtl2832_sdr_try_fmt_sdr_cap (struct file *file, +struct video_device_state *state,struct v4l2_format *f) {struct rtl2832_sdr_dev *dev =video_drvdata (file);struct platform_device *pdev = dev->pdev;
drivers/media/i2c/video-i2c.c +26 -13
@@ -558,7 +558,8 @@ static const struct vb2_ops video_i2c_video_qops = { .stop_streaming = stop_streaming, }; -static int video_i2c_querycap (struct file *file,void *priv, +static int video_i2c_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *vcap) {struct video_i2c_data *data =video_drvdata (file);
@@ -573,19 +574,24 @@ static int video_i2c_querycap(struct file *file, void *priv,return 0 ; } -static int video_i2c_g_input (struct file *file,void *fh,unsigned int *inp) +static int video_i2c_g_input (struct file *file, +struct video_device_state *state, +unsigned int *inp) { *inp =0 ;return 0 ; } -static int video_i2c_s_input (struct file *file,void *fh,unsigned int inp) +static int video_i2c_s_input (struct file *file, +struct video_device_state *state, +unsigned int inp) {return (inp >0 ) ? -EINVAL :0 ; } -static int video_i2c_enum_input (struct file *file,void *fh, +static int video_i2c_enum_input (struct file *file, +struct video_device_state *state,struct v4l2_input *vin) {if (vin->index >0 )
@@ -598,7 +604,8 @@ static int video_i2c_enum_input(struct file *file, void *fh,return 0 ; } -static int video_i2c_enum_fmt_vid_cap (struct file *file,void *fh, +static int video_i2c_enum_fmt_vid_cap (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *fmt) {struct video_i2c_data *data =video_drvdata (file);
@@ -613,7 +620,8 @@ static int video_i2c_enum_fmt_vid_cap(struct file *file, void *fh,return 0 ; } -static int video_i2c_enum_framesizes (struct file *file,void *fh, +static int video_i2c_enum_framesizes (struct file *file, +struct video_device_state *state,struct v4l2_frmsizeenum *fsize) {const struct video_i2c_data *data =video_drvdata (file);
@@ -633,7 +641,8 @@ static int video_i2c_enum_framesizes(struct file *file, void *fh,return 0 ; } -static int video_i2c_enum_frameintervals (struct file *file,void *priv, +static int video_i2c_enum_frameintervals (struct file *file, +struct video_device_state *state,struct v4l2_frmivalenum *fe) {const struct video_i2c_data *data =video_drvdata (file);
@@ -651,7 +660,8 @@ static int video_i2c_enum_frameintervals(struct file *file, void *priv,return 0 ; } -static int video_i2c_try_fmt_vid_cap (struct file *file,void *fh, +static int video_i2c_try_fmt_vid_cap (struct file *file, +struct video_device_state *state,struct v4l2_format *fmt) {const struct video_i2c_data *data =video_drvdata (file);
@@ -670,7 +680,8 @@ static int video_i2c_try_fmt_vid_cap(struct file *file, void *fh,return 0 ; } -static int video_i2c_s_fmt_vid_cap (struct file *file,void *fh, +static int video_i2c_s_fmt_vid_cap (struct file *file, +struct video_device_state *state,struct v4l2_format *fmt) {struct video_i2c_data *data =video_drvdata (file);
@@ -678,10 +689,11 @@ static int video_i2c_s_fmt_vid_cap(struct file *file, void *fh,if (vb2_is_busy (&data->vb_vidq))return -EBUSY ; -return video_i2c_try_fmt_vid_cap (file, fh, fmt); +return video_i2c_try_fmt_vid_cap (file, state, fmt); } -static int video_i2c_g_parm (struct file *filp,void *priv, +static int video_i2c_g_parm (struct file *filp, +struct video_device_state *state,struct v4l2_streamparm *parm) {struct video_i2c_data *data =video_drvdata (filp);
@@ -696,7 +708,8 @@ static int video_i2c_g_parm(struct file *filp, void *priv,return 0 ; } -static int video_i2c_s_parm (struct file *filp,void *priv, +static int video_i2c_s_parm (struct file *filp, +struct video_device_state *state,struct v4l2_streamparm *parm) {struct video_i2c_data *data =video_drvdata (filp);
@@ -709,7 +722,7 @@ static int video_i2c_s_parm(struct file *filp, void *priv, } data->frame_interval = data->chip->frame_intervals[i]; -return video_i2c_g_parm (filp, priv, parm); +return video_i2c_g_parm (filp, state, parm); }static const struct v4l2_ioctl_ops video_i2c_ioctl_ops = {
drivers/media/pci/bt8xx/bttv-driver.c +56 -28
246 lines not on this page · raw message
drivers/media/pci/bt8xx/bttv-vbi.c +6 -5
@@ -241,7 +241,8 @@ static int try_fmt(struct v4l2_vbi_format *f, const struct bttv_tvnorm *tvnorm,return 0 ; } -int bttv_try_fmt_vbi_cap (struct file *file,void *priv,struct v4l2_format *frt) +int bttv_try_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *frt) {struct bttv *btv =video_drvdata (file);const struct bttv_tvnorm *tvnorm;
@@ -257,8 +258,8 @@ int bttv_try_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)return try_fmt (&frt->fmt.vbi, tvnorm, crop_start); } - -int bttv_s_fmt_vbi_cap (struct file *file,void *priv,struct v4l2_format *frt) +int bttv_s_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *frt) {struct bttv *btv =video_drvdata (file);const struct bttv_tvnorm *tvnorm;
@@ -300,8 +301,8 @@ int bttv_s_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)return rc; } - -int bttv_g_fmt_vbi_cap (struct file *file,void *priv,struct v4l2_format *frt) +int bttv_g_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *frt) {const struct bttv_tvnorm *tvnorm;struct bttv *btv =video_drvdata (file);
drivers/media/pci/bt8xx/bttvp.h +6 -3
@@ -227,9 +227,12 @@ int bttv_buffer_activate_vbi(struct bttv *btv,#define VBI_DEFLINES 16 -int bttv_try_fmt_vbi_cap (struct file *file,void *fh,struct v4l2_format *f); -int bttv_g_fmt_vbi_cap (struct file *file,void *fh,struct v4l2_format *f); -int bttv_s_fmt_vbi_cap (struct file *file,void *fh,struct v4l2_format *f); +int bttv_try_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *f); +int bttv_g_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *f); +int bttv_s_fmt_vbi_cap (struct file *file,struct video_device_state *state, +struct v4l2_format *f);/* ---------------------------------------------------------- */ /* bttv-gpio.c */
drivers/media/pci/cobalt/cobalt-v4l2.c +59 -39
275 lines not on this page · raw message
drivers/media/pci/cx18/cx18-driver.c +3 -6
@@ -1136,11 +1136,8 @@ int cx18_init_on_first_open(struct cx18 *cx)int video_input;int fw_retry_count =3 ;struct v4l2_frequency vf; -struct cx18_open_id fh;v4l2_std_id std; - fh.cx = cx; -if (test_bit (CX18_F_I_FAILED , &cx->i_flags))return -ENXIO ;
@@ -1220,14 +1217,14 @@ int cx18_init_on_first_open(struct cx18 *cx) video_input = cx->active_input; cx->active_input++;/* Force update of input */ -cx18_s_input (NULL , &fh, video_input); +cx18_s_input (NULL ,NULL , video_input);/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code in one place. */ cx->std++;/* Force full standard initialization */ std = (cx->tuner_std ==V4L2_STD_ALL ) ?V4L2_STD_NTSC_M : cx->tuner_std; -cx18_s_std (NULL , &fh, std); -cx18_s_frequency (NULL , &fh, &vf); +cx18_s_std (NULL ,NULL , std); +cx18_s_frequency (NULL ,NULL , &vf);return 0 ; }
drivers/media/pci/cx18/cx18-ioctl.c +73 -41
330 lines not on this page · raw message
drivers/media/pci/cx18/cx18-ioctl.h +6 -3
@@ -12,6 +12,9 @@ u16 cx18_service2vbi(int type);void cx18_expand_service_set (struct v4l2_sliced_vbi_format *fmt,int is_pal);u16 cx18_get_service_set (struct v4l2_sliced_vbi_format *fmt);void cx18_set_funcs (struct video_device *vdev); -int cx18_s_std (struct file *file,void *fh,v4l2_std_id std); -int cx18_s_frequency (struct file *file,void *fh,const struct v4l2_frequency *vf); -int cx18_s_input (struct file *file,void *fh,unsigned int inp); +int cx18_s_std (struct file *file,struct video_device_state *state, +v4l2_std_id std); +int cx18_s_frequency (struct file *file,struct video_device_state *state, +const struct v4l2_frequency *vf); +int cx18_s_input (struct file *file,struct video_device_state *state, +unsigned int inp);
drivers/media/pci/cx23885/cx23885-417.c +33 -20
134 lines not on this page · raw message
drivers/media/pci/cx23885/cx23885-ioctl.c +4 -4
@@ -11,8 +11,8 @@#include "cx23885-ioctl.h" #ifdef CONFIG_VIDEO_ADV_DEBUG -int cx23885_g_chip_info (struct file *file,void *fh, -struct v4l2_dbg_chip_info *chip) +int cx23885_g_chip_info (struct file *file,struct video_device_state *state, +struct v4l2_dbg_chip_info *chip) {struct cx23885_dev *dev =video_drvdata (file);
@@ -47,7 +47,7 @@ static int cx23417_g_register(struct cx23885_dev *dev,return 0 ; } -int cx23885_g_register (struct file *file,void *fh, +int cx23885_g_register (struct file *file,struct video_device_state *state,struct v4l2_dbg_register *reg) {struct cx23885_dev *dev =video_drvdata (file);
@@ -79,7 +79,7 @@ static int cx23417_s_register(struct cx23885_dev *dev,return 0 ; } -int cx23885_s_register (struct file *file,void *fh, +int cx23885_s_register (struct file *file,struct video_device_state *state,const struct v4l2_dbg_register *reg) {struct cx23885_dev *dev =video_drvdata (file);
drivers/media/pci/cx23885/cx23885-ioctl.h +4 -5
@@ -10,15 +10,14 @@#ifndef _CX23885_IOCTL_H_#define _CX23885_IOCTL_H_ -int cx23885_g_chip_info (struct file *file,void *fh, -struct v4l2_dbg_chip_info *chip); +int cx23885_g_chip_info (struct file *file,struct video_device_state *state, +struct v4l2_dbg_chip_info *chip);#ifdef CONFIG_VIDEO_ADV_DEBUG -int cx23885_g_register (struct file *file,void *fh, +int cx23885_g_register (struct file *file,struct video_device_state *state,struct v4l2_dbg_register *reg); - -int cx23885_s_register (struct file *file,void *fh, +int cx23885_s_register (struct file *file,struct video_device_state *state,const struct v4l2_dbg_register *reg);#endif
drivers/media/pci/cx23885/cx23885-vbi.c +2 -3
@@ -32,9 +32,8 @@ MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]");#define VBI_NTSC_LINE_COUNT 12#define VBI_PAL_LINE_COUNT 18 - -int cx23885_vbi_fmt (struct file *file,void *priv, -struct v4l2_format *f) +int cx23885_vbi_fmt (struct file *file,struct video_device_state *state, +struct v4l2_format *f) {struct cx23885_dev *dev =video_drvdata (file);
drivers/media/pci/cx23885/cx23885-video.c +47 -35
207 lines not on this page · raw message
drivers/media/pci/cx23885/cx23885.h +2 -2
@@ -585,8 +585,8 @@ int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm);/* ----------------------------------------------------------- */ /* cx23885-vbi.c */ -extern int cx23885_vbi_fmt (struct file *file,void *priv, -struct v4l2_format *f); +int cx23885_vbi_fmt (struct file *file,struct video_device_state *state, +struct v4l2_format *f);extern void cx23885_vbi_timeout (unsigned long data);extern const struct vb2_ops cx23885_vbi_qops;extern int cx23885_vbi_irq (struct cx23885_dev *dev,u32 status);
drivers/media/pci/cx25821/cx25821-video.c +39 -18
160 lines not on this page · raw message
drivers/media/pci/cx88/cx88-blackbird.c +31 -16
143 lines not on this page · raw message
drivers/media/pci/cx88/cx88-vbi.c +1 -1
@@ -20,7 +20,7 @@ MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]");/* ------------------------------------------------------------------ */ -int cx8800_vbi_fmt (struct file *file,void *priv, +int cx8800_vbi_fmt (struct file *file,struct video_device_state *state,struct v4l2_format *f) {struct cx8800_dev *dev =video_drvdata (file);
drivers/media/pci/cx88/cx88-video.c +37 -19
168 lines not on this page · raw message
drivers/media/pci/cx88/cx88.h +1 -1
@@ -656,7 +656,7 @@ int cx88_stop_audio_dma(struct cx88_core *core);/* cx88-vbi.c */ /* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ -int cx8800_vbi_fmt (struct file *file,void *priv, +int cx8800_vbi_fmt (struct file *file,struct video_device_state *state,struct v4l2_format *f);void cx8800_stop_vbi_dma (struct cx8800_dev *dev);
drivers/media/pci/dt3155/dt3155.c +17 -8
@@ -285,7 +285,8 @@ static const struct v4l2_file_operations dt3155_fops = { .poll = vb2_fop_poll }; -static int dt3155_querycap (struct file *filp,void *p, +static int dt3155_querycap (struct file *filp, +struct video_device_state *state,struct v4l2_capability *cap) {strscpy (cap->driver,DT3155_NAME ,sizeof (cap->driver));
@@ -294,7 +295,8 @@ static int dt3155_querycap(struct file *filp, void *p, }static int dt3155_enum_fmt_vid_cap (struct file *filp, -void *p,struct v4l2_fmtdesc *f) +struct video_device_state *state, +struct v4l2_fmtdesc *f) {if (f->index)return -EINVAL ;
@@ -302,7 +304,9 @@ static int dt3155_enum_fmt_vid_cap(struct file *filp,return 0 ; } -static int dt3155_fmt_vid_cap (struct file *filp,void *p,struct v4l2_format *f) +static int dt3155_fmt_vid_cap (struct file *filp, +struct video_device_state *state, +struct v4l2_format *f) {struct dt3155_priv *pd =video_drvdata (filp);
@@ -316,7 +320,8 @@ static int dt3155_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)return 0 ; } -static int dt3155_g_std (struct file *filp,void *p,v4l2_std_id *norm) +static int dt3155_g_std (struct file *filp,struct video_device_state *state, +v4l2_std_id *norm) {struct dt3155_priv *pd =video_drvdata (filp);
@@ -324,7 +329,8 @@ static int dt3155_g_std(struct file *filp, void *p, v4l2_std_id *norm)return 0 ; } -static int dt3155_s_std (struct file *filp,void *p,v4l2_std_id norm) +static int dt3155_s_std (struct file *filp,struct video_device_state *state, +v4l2_std_id norm) {struct dt3155_priv *pd =video_drvdata (filp);
@@ -345,7 +351,8 @@ static int dt3155_s_std(struct file *filp, void *p, v4l2_std_id norm)return 0 ; } -static int dt3155_enum_input (struct file *filp,void *p, +static int dt3155_enum_input (struct file *filp, +struct video_device_state *state,struct v4l2_input *input) {if (input->index >3 )
@@ -361,7 +368,8 @@ static int dt3155_enum_input(struct file *filp, void *p,return 0 ; } -static int dt3155_g_input (struct file *filp,void *p,unsigned int *i) +static int dt3155_g_input (struct file *filp,struct video_device_state *state, +unsigned int *i) {struct dt3155_priv *pd =video_drvdata (filp);
@@ -369,7 +377,8 @@ static int dt3155_g_input(struct file *filp, void *p, unsigned int *i)return 0 ; } -static int dt3155_s_input (struct file *filp,void *p,unsigned int i) +static int dt3155_s_input (struct file *filp,struct video_device_state *state, +unsigned int i) {struct dt3155_priv *pd =video_drvdata (filp);
drivers/media/pci/intel/ipu3/ipu3-cio2.c +20 -9
@@ -1062,7 +1062,8 @@ static const struct vb2_ops cio2_vb2_ops = {/**************** V4L2 interface ****************/ -static int cio2_v4l2_querycap (struct file *file,void *fh, +static int cio2_v4l2_querycap (struct file *file, +struct video_device_state *state,struct v4l2_capability *cap) {strscpy (cap->driver,CIO2_NAME ,sizeof (cap->driver));
@@ -1071,7 +1072,8 @@ static int cio2_v4l2_querycap(struct file *file, void *fh,return 0 ; } -static int cio2_v4l2_enum_fmt (struct file *file,void *fh, +static int cio2_v4l2_enum_fmt (struct file *file, +struct video_device_state *state,struct v4l2_fmtdesc *f) {if (f->index >=ARRAY_SIZE (formats))
@@ -1083,7 +1085,9 @@ static int cio2_v4l2_enum_fmt(struct file *file, void *fh, }/* The format is validated in cio2_video_link_validate() */ -static int cio2_v4l2_g_fmt (struct file *file,void *fh,struct v4l2_format *f) +static int cio2_v4l2_g_fmt (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct cio2_queue *q =file_to_cio2_queue (file);
@@ -1092,7 +1096,9 @@ static int cio2_v4l2_g_fmt(struct file *file, void *fh, struct v4l2_format *f)return 0 ; } -static int cio2_v4l2_try_fmt (struct file *file,void *fh,struct v4l2_format *f) +static int cio2_v4l2_try_fmt (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {const struct ipu3_cio2_fmt *fmt;struct v4l2_pix_format_mplane *mpix = &f->fmt.pix_mp;
@@ -1123,18 +1129,21 @@ static int cio2_v4l2_try_fmt(struct file *file, void *fh, struct v4l2_format *f)return 0 ; } -static int cio2_v4l2_s_fmt (struct file *file,void *fh,struct v4l2_format *f) +static int cio2_v4l2_s_fmt (struct file *file, +struct video_device_state *state, +struct v4l2_format *f) {struct cio2_queue *q =file_to_cio2_queue (file); -cio2_v4l2_try_fmt (file, fh, f); +cio2_v4l2_try_fmt (file, state, f); q->format = f->fmt.pix_mp;return 0 ; }static int -cio2_video_enum_input (struct file *file,void *fh,struct v4l2_input *input) +cio2_video_enum_input (struct file *file,struct video_device_state *state, +struct v4l2_input *input) {if (input->index >0 )return -EINVAL ;
@@ -1146,7 +1155,8 @@ cio2_video_enum_input(struct file *file, void *fh, struct v4l2_input *input) }static int -cio2_video_g_input (struct file *file,void *fh,unsigned int *input) +cio2_video_g_input (struct file *file,struct video_device_state *state, +unsigned int *input) { *input =0 ;
@@ -1154,7 +1164,8 @@ cio2_video_g_input(struct file *file, void *fh, unsigned int *input) }static int -cio2_video_s_input (struct file *file,void *fh,unsigned int input) +cio2_video_s_input (struct file *file,struct video_device_state *state, +unsigned int input) {return input ==0 ?0 : -EINVAL ; }
drivers/media/pci/intel/ipu6/ipu6-isys-video.c +26 -15
123 lines not on this page · raw message
drivers/media/pci/ivtv/ivtv-driver.c +2 -6
@@ -1249,13 +1249,9 @@ int ivtv_init_on_first_open(struct ivtv *itv) {struct v4l2_frequency vf;/* Needed to call ioctls later */ -struct ivtv_open_id fh;int fw_retry_count =3 ;int video_input; - fh.itv = itv; - fh.type =IVTV_ENC_STREAM_TYPE_MPG ; -if (test_bit (IVTV_F_I_FAILED , &itv->i_flags))return -ENXIO ;
@@ -1297,13 +1293,13 @@ int ivtv_init_on_first_open(struct ivtv *itv) video_input = itv->active_input; itv->active_input++;/* Force update of input */ -ivtv_s_input (NULL , &fh, video_input); +ivtv_s_input (NULL ,NULL , video_input);/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code in one place. */ itv->std++;/* Force full standard initialization */ itv->std_out = itv->std; -ivtv_s_frequency (NULL , &fh, &vf); +ivtv_s_frequency (NULL ,NULL , &vf);if (itv->card->v4l2_capabilities &V4L2_CAP_VIDEO_OUTPUT ) {/* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes
drivers/media/pci/ivtv/ivtv-ioctl.c +156 -69
150 lines not on this page · raw message
drivers/media/pci/mgb4/mgb4_vin.c +36 -19
55 lines not on this page · raw message
drivers/media/pci/mgb4/mgb4_vout.c +32 -17
49 lines not on this page · raw message
drivers/media/pci/saa7134/saa7134-empress.c +8 -4
Lines of this file are not shown. View the raw message.
drivers/media/pci/saa7134/saa7134-video.c +58 -38
96 lines not on this page · raw message
drivers/media/pci/saa7146/hexium_gemini.c +7 -3
Lines of this file are not shown. View the raw message.
drivers/media/pci/saa7146/hexium_orion.c +7 -3
Lines of this file are not shown. View the raw message.
drivers/media/pci/saa7146/mxb.c +33 -13
46 lines not on this page · raw message
drivers/media/pci/saa7164/saa7164-encoder.c +24 -15
Lines of this file are not shown. View the raw message.
drivers/media/pci/saa7164/saa7164-vbi.c +16 -11
Lines of this file are not shown. View the raw message.
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +30 -16
46 lines not on this page · raw message
drivers/media/pci/solo6x10/solo6x10-v4l2.c +21 -11
Lines of this file are not shown. View the raw message.
drivers/media/pci/tw5864/tw5864-video.c +32 -17
49 lines not on this page · raw message
drivers/media/pci/tw68/tw68-video.c +28 -15
43 lines not on this page · raw message
drivers/media/pci/tw686x/tw686x-video.c +34 -19
53 lines not on this page · raw message
drivers/media/pci/zoran/zoran_driver.c +29 -15
44 lines not on this page · raw message
drivers/media/platform/allegro-dvt/allegro-core.c +31 -18
49 lines not on this page · raw message
drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/amlogic/c3/isp/c3-isp-params.c +6 -3
Lines of this file are not shown. View the raw message.
drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c +6 -3
Lines of this file are not shown. View the raw message.
drivers/media/platform/amlogic/meson-ge2d/ge2d.c +25 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/amphion/vdec.c +19 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/amphion/venc.c +33 -16
49 lines not on this page · raw message
drivers/media/platform/aspeed/aspeed-video.c +34 -16
50 lines not on this page · raw message
drivers/media/platform/atmel/atmel-isi.c +24 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/broadcom/bcm2835-unicam.c +22 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/chips-media/coda/coda-common.c +43 -26
69 lines not on this page · raw message
drivers/media/platform/chips-media/wave5/wave5-helper.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/media/platform/chips-media/wave5/wave5-helper.h +2 -1
Lines of this file are not shown. View the raw message.
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +39 -15
54 lines not on this page · raw message
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +45 -17
62 lines not on this page · raw message
drivers/media/platform/imagination/e5010-jpeg-enc.c +23 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/intel/pxa_camera.c +23 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/m2m-deinterlace.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/marvell/mcam-core.c +30 -22
52 lines not on this page · raw message
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +28 -16
44 lines not on this page · raw message
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c +16 -9
Lines of this file are not shown. View the raw message.
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +34 -18
52 lines not on this page · raw message
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +33 -17
50 lines not on this page · raw message
drivers/media/platform/microchip/microchip-isc-base.c +22 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/nuvoton/npcm-video.c +29 -14
43 lines not on this page · raw message
drivers/media/platform/nvidia/tegra-vde/v4l2.c +24 -14
Lines of this file are not shown. View the raw message.
drivers/media/platform/nxp/dw100/dw100.c +23 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +33 -19
52 lines not on this page · raw message
drivers/media/platform/nxp/imx7-media-csi.c +14 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +10 -5
Lines of this file are not shown. View the raw message.
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/nxp/mx2_emmaprp.c +20 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/qcom/camss/camss-video.c +18 -9
Lines of this file are not shown. View the raw message.
drivers/media/platform/qcom/iris/iris_vidc.c +33 -15
48 lines not on this page · raw message
drivers/media/platform/qcom/venus/vdec.c +19 -10
Lines of this file are not shown. View the raw message.
drivers/media/platform/qcom/venus/venc.c +25 -13
Lines of this file are not shown. View the raw message.
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c +27 -15
42 lines not on this page · raw message
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c +26 -14
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c +14 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/rcar_drif.c +20 -10
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/rcar_fdp1.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/rcar_jpu.c +14 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/renesas-ceu.c +24 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/sh_vou.c +27 -14
41 lines not on this page · raw message
drivers/media/platform/renesas/vsp1/vsp1_histo.c +6 -3
Lines of this file are not shown. View the raw message.
drivers/media/platform/renesas/vsp1/vsp1_video.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/rga/rga.c +16 -8
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +10 -5
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c +6 -3
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/rkvdec/rkvdec.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c +29 -15
44 lines not on this page · raw message
drivers/media/platform/samsung/exynos4-is/fimc-capture.c +29 -16
45 lines not on this page · raw message
drivers/media/platform/samsung/exynos4-is/fimc-isp-video.c +20 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/exynos4-is/fimc-lite.c +23 -13
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/exynos4-is/fimc-m2m.c +14 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/s3c-camif/camif-capture.c +36 -18
54 lines not on this page · raw message
drivers/media/platform/samsung/s5p-g2d/g2d.c +17 -9
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c +31 -17
48 lines not on this page · raw message
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c +33 -18
51 lines not on this page · raw message
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c +17 -9
Lines of this file are not shown. View the raw message.
drivers/media/platform/st/sti/delta/delta-v4l2.c +29 -15
44 lines not on this page · raw message
drivers/media/platform/st/sti/hva/hva-v4l2.c +31 -15
46 lines not on this page · raw message
drivers/media/platform/st/stm32/dma2d/dma2d.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/platform/st/stm32/stm32-dcmi.c +28 -14
42 lines not on this page · raw message
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c +13 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c +16 -9
Lines of this file are not shown. View the raw message.
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +16 -8
Lines of this file are not shown. View the raw message.
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c +20 -11
Lines of this file are not shown. View the raw message.
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +32 -15
47 lines not on this page · raw message
drivers/media/platform/ti/am437x/am437x-vpfe.c +34 -18
52 lines not on this page · raw message
drivers/media/platform/ti/cal/cal-video.c +37 -17
54 lines not on this page · raw message
drivers/media/platform/ti/davinci/vpif_capture.c +54 -40
94 lines not on this page · raw message
drivers/media/platform/ti/davinci/vpif_display.c +36 -22
58 lines not on this page · raw message
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +13 -7
Lines of this file are not shown. View the raw message.
drivers/media/platform/ti/omap/omap_vout.c +32 -17
49 lines not on this page · raw message
drivers/media/platform/ti/omap3isp/ispvideo.c +35 -18
53 lines not on this page · raw message
drivers/media/platform/verisilicon/hantro_v4l2.c +30 -17
47 lines not on this page · raw message
drivers/media/platform/via/via-camera.c +24 -18
42 lines not on this page · raw message
drivers/media/platform/xilinx/xilinx-dma.c +10 -5
Lines of this file are not shown. View the raw message.
drivers/media/radio/si470x/radio-si470x-common.c +15 -10
Lines of this file are not shown. View the raw message.
drivers/media/radio/si4713/radio-platform-si4713.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/media/radio/si4713/radio-usb-si4713.c +10 -5
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vicodec/vicodec-core.c +34 -20
54 lines not on this page · raw message
drivers/media/test-drivers/vim2m.c +36 -20
56 lines not on this page · raw message
drivers/media/test-drivers/vimc/vimc-capture.c +13 -7
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/visl/visl-video.c +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-core.c +119 -84
203 lines not on this page · raw message
drivers/media/test-drivers/vivid/vivid-meta-cap.c +4 -2
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-meta-cap.h +4 -2
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-meta-out.c +4 -2
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-meta-out.h +6 -3
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-radio-rx.c +12 -4
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-radio-rx.h +12 -4
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-radio-tx.c +4 -2
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-radio-tx.h +4 -2
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-sdr-cap.c +20 -10
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-sdr-cap.h +21 -9
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-touch-cap.c +15 -7
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-touch-cap.h +15 -7
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vbi-cap.c +18 -8
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vbi-cap.h +16 -6
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vbi-out.c +14 -8
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vbi-out.h +13 -5
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vid-cap.c +74 -40
114 lines not on this page · raw message
drivers/media/test-drivers/vivid/vivid-vid-cap.h +82 -35
117 lines not on this page · raw message
drivers/media/test-drivers/vivid/vivid-vid-common.c +15 -9
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vid-common.h +22 -12
Lines of this file are not shown. View the raw message.
drivers/media/test-drivers/vivid/vivid-vid-out.c +69 -53
122 lines not on this page · raw message
drivers/media/test-drivers/vivid/vivid-vid-out.h +67 -28
95 lines not on this page · raw message
drivers/media/usb/au0828/au0828-video.c +49 -25
74 lines not on this page · raw message
drivers/media/usb/cx231xx/cx231xx-417.c +18 -10
Lines of this file are not shown. View the raw message.
drivers/media/usb/cx231xx/cx231xx-video.c +52 -27
79 lines not on this page · raw message
drivers/media/usb/dvb-usb/cxusb-analog.c +32 -16
48 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx-video.c +58 -29
87 lines not on this page · raw message
drivers/media/usb/go7007/go7007-v4l2.c +49 -26
75 lines not on this page · raw message
drivers/media/usb/gspca/gspca.c +34 -17
51 lines not on this page · raw message
drivers/media/usb/hdpvr/hdpvr-video.c +39 -21
60 lines not on this page · raw message
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +67 -31
98 lines not on this page · raw message
drivers/media/usb/pwc/pwc-v4l.c +30 -14
44 lines not on this page · raw message
drivers/media/usb/s2255/s2255drv.c +36 -19
55 lines not on this page · raw message
drivers/media/usb/stk1160/stk1160-v4l.c +26 -14
Lines of this file are not shown. View the raw message.
drivers/media/usb/uvc/uvc_v4l2.c +40 -19
59 lines not on this page · raw message
drivers/media/v4l2-core/v4l2-ctrls-api.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/media/v4l2-core/v4l2-mem2mem.c +34 -22
56 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +47 -25
72 lines not on this page · raw message
drivers/staging/media/av7110/av7110_v4l.c +42 -18
60 lines not on this page · raw message
drivers/staging/media/deprecated/atmel/atmel-isc-base.c +22 -11
Lines of this file are not shown. View the raw message.
drivers/staging/media/imx/imx-media-capture.c +36 -17
53 lines not on this page · raw message
drivers/staging/media/imx/imx-media-csc-scaler.c +15 -8
Lines of this file are not shown. View the raw message.
drivers/staging/media/ipu3/ipu3-v4l2.c +19 -10
Lines of this file are not shown. View the raw message.
drivers/staging/media/ipu7/ipu7-isys-video.c +19 -11
Lines of this file are not shown. View the raw message.
drivers/staging/media/meson/vdec/vdec.c +17 -9
Lines of this file are not shown. View the raw message.
drivers/staging/media/starfive/camss/stf-video.c +12 -6
Lines of this file are not shown. View the raw message.
drivers/staging/media/sunxi/cedrus/cedrus_video.c +19 -10
Lines of this file are not shown. View the raw message.
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +16 -8
Lines of this file are not shown. View the raw message.
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +6 -3
Lines of this file are not shown. View the raw message.
drivers/staging/media/tegra-video/vi.c +45 -23
68 lines not on this page · raw message
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +38 -20
58 lines not on this page · raw message
drivers/usb/gadget/function/uvc_v4l2.c +33 -17
50 lines not on this page · raw message
include/media/v4l2-ioctl.h +120 -118
238 lines not on this page · raw message
include/media/v4l2-mem2mem.h +32 -16
48 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.51.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 06/10] media: Replace void * with video_device_state * in all driver ioctl implementations
Hi Jai,
This patch is too large to be reasonably reviewable in its current form.
The stated change is conceptually simple: replace the opaque void *priv argument with struct video_device_state *state in V4L2 ioctl implementations. However, this single patch touches hundreds of files across drivers, helpers, framework code, staging code, and public headers. That makes it extremely difficult to validate correctness, spot exceptions, and reason about regressions from mailing list review alone.
A few issues stand out:
1. Patch granularity
This should not be one monolithic patch. At minimum it should be split into:
- core/framework changes
- helper conversions
- driver conversions by subsystem or directory class
- staging/test-driver conversions separately
Right now the size alone makes meaningful review and bisection much worse than it needs to be.
2. Mechanical conversion claim vs. manual exceptions
The changelog says most changes were automated with Coccinelle, while function signature updates in headers and edge cases were handled manually. That is exactly why this needs splitting. Mechanical treewide conversions are one thing; manual edge-case handling is where subtle semantic mistakes tend to hide.
3. API conversion proof is missing
If this is primarily a scripted transformation, the review should center on the semantic patch and on proving there are no remaining mismatches.
Please include:
- the Coccinelle script as a separate patch or in the cover letter
- a summary of what could not be converted automatically
- a treewide grep result showing there are no remaining ioctl prototypes using void *priv where
struct video_device_state *state is now required
4. Conversion consistency
Several call sites now rename the parameter to state but continue to use it only as a positional placeholder, which is fine mechanically, but the patch should avoid mixing semantic conversion with opportunistic cleanup. Formatting-only churn and spacing adjustments should be kept to the minimum necessary for the signature change.
5. Risk concentration
This patch touches both framework headers and many driver implementations in the same changeset. That amplifies the blast radius of any mistake and makes it harder to tell whether a reported regression belongs to the API change itself or to one of the driver-side edits.
6. Reviewability for maintainers
The CC list spans a large number of maintainers and mailing lists. That is appropriate for notification, but not a substitute for reviewable patch structure. Individual maintainers should not have to sift through a large treewide refactor to find the parts that affect their drivers.
Please respin this as a structured series with the mechanical transformation isolated from the framework changes and with a clear accounting of manual fixups and exceptions.
As it stands, I do not think this patch is reviewable in one piece.
Acked By : David Dull
Laurent Pinchart
maintainerRe: [PATCH v2 06/10] media: Replace void * with video_device_state * in all driver ioctl implementations
Quoted 3 lines · David Dull
Hi Jai,
This patch is too large to be reasonably reviewable in its current form.
This review is too generated by LLMs to be actionable in its current form.
Quoted 77 lines
The stated change is conceptually simple: replace the opaque
void *privargument withstruct video_device_state *statein V4L2 ioctl implementations. However, this single patch touches hundreds of files across drivers, helpers, framework code, staging code, and public headers. That makes it extremely difficult to validate correctness, spot exceptions, and reason about regressions from mailing list review alone.A few issues stand out:
1. Patch granularity
This should not be one monolithic patch. At minimum it should be split into:
- core/framework changes
- helper conversions
- driver conversions by subsystem or directory class
- staging/test-driver conversions separatelyRight now the size alone makes meaningful review and bisection much worse than it needs to be.
2. Mechanical conversion claim vs. manual exceptions
The changelog says most changes were automated with Coccinelle, while function signature updates in headers and edge cases were handled manually. That is exactly why this needs splitting. Mechanical treewide conversions are one thing; manual edge-case handling is where subtle semantic mistakes tend to hide.
3. API conversion proof is missing
If this is primarily a scripted transformation, the review should center on the semantic patch and on proving there are no remaining mismatches.
Please include:
- the Coccinelle script as a separate patch or in the cover letter
- a summary of what could not be converted automatically
- a treewide grep result showing there are no remaining ioctl prototypes usingvoid *privwhere
struct video_device_state *stateis now required4. Conversion consistency
Several call sites now rename the parameter to
statebut continue to use it only as a positional placeholder, which is fine mechanically, but the patch should avoid mixing semantic conversion with opportunistic cleanup. Formatting-only churn and spacing adjustments should be kept to the minimum necessary for the signature change.5. Risk concentration
This patch touches both framework headers and many driver implementations in the same changeset. That amplifies the blast radius of any mistake and makes it harder to tell whether a reported regression belongs to the API change itself or to one of the driver-side edits.
6. Reviewability for maintainers
The CC list spans a large number of maintainers and mailing lists. That is appropriate for notification, but not a substitute for reviewable patch structure. Individual maintainers should not have to sift through a large treewide refactor to find the parts that affect their drivers.
Please respin this as a structured series with the mechanical transformation isolated from the framework changes and with a clear accounting of manual fixups and exceptions.
As it stands, I do not think this patch is reviewable in one piece.
Acked By : David Dull
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 06/10] media: Replace void * with video_device_state * in all driver ioctl implementations
In reply to Jai LuthraHi Jai,
This patch is too large to be reasonably reviewable in its current form.
The stated change is conceptually simple: replace the opaque void *priv argument with struct video_device_state *state in V4L2 ioctl implementations. However, this single patch touches hundreds of files across drivers, helpers, framework code, staging code, and public headers. That makes it extremely difficult to validate correctness, spot exceptions, and reason about regressions from mailing list review alone.
A few issues stand out:
1. Patch granularity
This should not be one monolithic patch. At minimum it should be split into:
- core/framework changes
- helper conversions
- driver conversions by subsystem or directory class
- staging/test-driver conversions separately
Right now the size alone makes meaningful review and bisection much worse than it needs to be.
2. Mechanical conversion claim vs. manual exceptions
The changelog says most changes were automated with Coccinelle, while function signature updates in headers and edge cases were handled manually. That is exactly why this needs splitting. Mechanical treewide conversions are one thing; manual edge-case handling is where subtle semantic mistakes tend to hide.
3. API conversion proof is missing
If this is primarily a scripted transformation, the review should center on the semantic patch and on proving there are no remaining mismatches.
Please include:
- the Coccinelle script as a separate patch or in the cover letter
- a summary of what could not be converted automatically
- a treewide grep result showing there are no remaining ioctl prototypes using void *priv where
struct video_device_state *state is now required
4. Conversion consistency
Several call sites now rename the parameter to state but continue to use it only as a positional placeholder, which is fine mechanically, but the patch should avoid mixing semantic conversion with opportunistic cleanup. Formatting-only churn and spacing adjustments should be kept to the minimum necessary for the signature change.
5. Risk concentration
This patch touches both framework headers and many driver implementations in the same changeset. That amplifies the blast radius of any mistake and makes it harder to tell whether a reported regression belongs to the API change itself or to one of the driver-side edits.
6. Reviewability for maintainers
The CC list spans a large number of maintainers and mailing lists. That is appropriate for notification, but not a substitute for reviewable patch structure. Individual maintainers should not have to sift through a large treewide refactor to find the parts that affect their drivers.
Please respin this as a structured series with the mechanical transformation isolated from the framework changes and with a clear accounting of manual fixups and exceptions.
As it stands, I do not think this patch is reviewable in one piece.
PATCH v2 7/10 media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls
In reply to Jai LuthraNow that video device state is accepted as an argument in ioctl implementations across all video device drivers, populate that argument with the actual state data.
Pass the active state for G_FMT and S_FMT ioctls, and the try state for TRY_FMT ioctl to drivers that have opted to use device state for format storage.
--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/media/v4l2-core/v4l2-ioctl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +21 -2
@@ -3070,6 +3070,21 @@ void v4l_printk_ioctl(const char *prefix, unsigned int cmd) }EXPORT_SYMBOL (v4l_printk_ioctl); +static struct video_device_state * +video_device_get_state (struct video_device *vfd,struct v4l2_fh *vfh, +unsigned int cmd) +{ +switch (cmd) { +default : +return NULL ; +case VIDIOC_G_FMT : +case VIDIOC_S_FMT : +return vfd->state; +case VIDIOC_TRY_FMT : +return vfh->state; + } +} +static long __video_do_ioctl (struct file *file,unsigned int cmd,void *arg) {
@@ -3078,6 +3093,7 @@ static long __video_do_ioctl(struct file *file,struct mutex *lock;/* ioctl serialization mutex */ const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;bool write_only = false; +struct video_device_state *state =NULL ;struct v4l2_ioctl_info default_info;const struct v4l2_ioctl_info *info;struct v4l2_fh *vfh =file_to_v4l2_fh (file);
@@ -3090,6 +3106,9 @@ static long __video_do_ioctl(struct file *file,return ret; } +if (test_bit (V4L2_FL_USES_STATE , &vfd->flags)) + state =video_device_get_state (vfd, vfh, cmd); +/* * We need to serialize streamon/off with queueing new requests. * These ioctls may trigger the cancellation of a streaming
@@ -3138,11 +3157,11 @@ static long __video_do_ioctl(struct file *file, write_only =_IOC_DIR (cmd) == _IOC_WRITE;if (info != &default_info) { - ret = info->func (ops, file,NULL , arg); + ret = info->func (ops, file, state, arg); }else if (!ops->vidioc_default) { ret = -ENOTTY ; }else { - ret = ops->vidioc_default (file,NULL , + ret = ops->vidioc_default (file, state,v4l2_prio_check (vfd->prio, vfh->prio) >=0 , cmd, arg); }
Signature · 1 line
2.51.0
Re: [PATCH v2 07/10] media: v4l2-ioctl: Pass device state for G/S/TRY_FMT ioctls
Quoted 18 lines · Jai Luthra
Now that video device state is accepted as an argument in ioctl implementations across all video device drivers, populate that argument with the actual state data.
Pass the active state for
G_FMTandS_FMTioctls, and the try state forTRY_FMTioctl to drivers that have opted to use device state for format storage.Signed-off-by Jai Luthra <[email protected]>--
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Ricardo Ribalda <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Jai Luthra <[email protected]>
Cc: [email protected]
Cc: [email protected]
Quoted 3 lines
--- drivers/media/v4l2-core/v4l2-ioctl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
There is one more occurrence of this in v4l2_compat_ioctl32.c in function ctrl_is_pointer() where vidioc_query_ext_ctrl is called.
Regards,
Hans
Quoted 60 lines
drivers/media/v4l2-core/v4l2-ioctl.c +21
-2@@ -3070,6 +3070,21 @@ void v4l_printk_ioctl(const char *prefix, unsigned int cmd) }EXPORT_SYMBOL (v4l_printk_ioctl); +static struct video_device_state * +video_device_get_state (struct video_device *vfd,struct v4l2_fh *vfh, +unsigned int cmd) +{ +switch (cmd) { +default : +return NULL ; +case VIDIOC_G_FMT : +case VIDIOC_S_FMT : +return vfd->state; +case VIDIOC_TRY_FMT : +return vfh->state; + } +} +static long __video_do_ioctl (struct file *file,unsigned int cmd,void *arg) {@@ -3078,6 +3093,7 @@ static long __video_do_ioctl(struct file *file,struct mutex *lock;/* ioctl serialization mutex */ const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;bool write_only = false; +struct video_device_state *state =NULL ;struct v4l2_ioctl_info default_info;const struct v4l2_ioctl_info *info;struct v4l2_fh *vfh =file_to_v4l2_fh (file);@@ -3090,6 +3106,9 @@ static long __video_do_ioctl(struct file *file,return ret; } +if (test_bit (V4L2_FL_USES_STATE , &vfd->flags)) + state =video_device_get_state (vfd, vfh, cmd); +/* * We need to serialize streamon/off with queueing new requests. * These ioctls may trigger the cancellation of a streaming @@ -3138,11 +3157,11 @@ static long __video_do_ioctl(struct file *file, write_only =_IOC_DIR (cmd) == _IOC_WRITE;if (info != &default_info) { - ret = info->func (ops, file,NULL , arg); + ret = info->func (ops, file, state, arg); }else if (!ops->vidioc_default) { ret = -ENOTTY ; }else { - ret = ops->vidioc_default (file,NULL , + ret = ops->vidioc_default (file, state,v4l2_prio_check (vfd->prio, vfh->prio) >=0 , cmd, arg); }
PATCH v2 8/10 media: ti: j721e-csi2rx: Use video_device_state
In reply to Jai LuthraUse the newly introduced video_device_state to store the active V4L2 format for the video device.
This change allows using a single function for both .s_fmt and .try_fmt hooks, while leveraging the framework helper for the .g_fmt hook.
--
Cc: Jai Luthra <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 119 +++++++++++---------- 1 file changed, 62 insertions(+), 57 deletions(-)
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +62 -57
@@ -17,6 +17,7 @@#include <media/cadence/cdns-csi2rx.h> #include <media/mipi-csi2.h> +#include <media/v4l2-dev.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-mc.h>
@@ -110,7 +111,6 @@ struct ti_csi2rx_dev {struct v4l2_subdev *source;struct vb2_queue vidq;struct mutex mutex;/* To serialize ioctls. */ -struct v4l2_format v_fmt;struct ti_csi2rx_dma dma;u32 sequence;u8 pix_per_clk;
@@ -308,22 +308,19 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file,return 0 ; } -static int ti_csi2rx_g_fmt_vid_cap (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct ti_csi2rx_dev *csi =video_drvdata (file); - - *f = csi->v_fmt; - -return 0 ; -} - -static int ti_csi2rx_try_fmt_vid_cap (struct file *file, +static int ti_csi2rx_adj_fmt_vid_cap (struct file *file,struct video_device_state *state,struct v4l2_format *f) {const struct ti_csi2rx_fmt *fmt; +struct v4l2_format *format; + +if (state->which ==VIDEO_DEVICE_STATE_ACTIVE ) { +struct ti_csi2rx_dev *csi =video_drvdata (file); + +if (vb2_is_busy (csi->vdev.queue)) +return -EBUSY ; + }/* * Default to the first format if the requested pixel format code isn't
@@ -338,25 +335,8 @@ static int ti_csi2rx_try_fmt_vid_cap(struct file *file,ti_csi2rx_fill_fmt (fmt, f); -return 0 ; -} - -static int ti_csi2rx_s_fmt_vid_cap (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct ti_csi2rx_dev *csi =video_drvdata (file); -struct vb2_queue *q = &csi->vidq; -int ret; - -if (vb2_is_busy (q)) -return -EBUSY ; - - ret =ti_csi2rx_try_fmt_vid_cap (file, state, f); -if (ret <0 ) -return ret; - - csi->v_fmt = *f; + format =video_device_state_get_fmt (state); + *format = *f;return 0 ; }
@@ -390,12 +370,36 @@ static int ti_csi2rx_enum_framesizes(struct file *file,return 0 ; } +static int ti_csi2rx_vdev_init_state (struct video_device_state *state) +{ +const struct ti_csi2rx_fmt *fmt; +struct v4l2_pix_format *pix_fmt; + + fmt =find_format_by_fourcc (V4L2_PIX_FMT_UYVY ); +if (!fmt) +return -EINVAL ; + + state->fmt.type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; + pix_fmt = &state->fmt.fmt.pix; + pix_fmt->width =640 ; + pix_fmt->height =480 ; + pix_fmt->field =V4L2_FIELD_NONE ; + pix_fmt->colorspace =V4L2_COLORSPACE_SRGB ; + pix_fmt->ycbcr_enc =V4L2_YCBCR_ENC_601 ; + pix_fmt->quantization =V4L2_QUANTIZATION_LIM_RANGE ; + pix_fmt->xfer_func =V4L2_XFER_FUNC_SRGB ; + +ti_csi2rx_fill_fmt (fmt, &state->fmt); + +return 0 ; +} +static const struct v4l2_ioctl_ops csi_ioctl_ops = { .vidioc_querycap = ti_csi2rx_querycap, .vidioc_enum_fmt_vid_cap = ti_csi2rx_enum_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = ti_csi2rx_try_fmt_vid_cap, - .vidioc_g_fmt_vid_cap = ti_csi2rx_g_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = ti_csi2rx_s_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = ti_csi2rx_adj_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = video_device_g_fmt, + .vidioc_s_fmt_vid_cap = ti_csi2rx_adj_fmt_vid_cap, .vidioc_enum_framesizes = ti_csi2rx_enum_framesizes, .vidioc_reqbufs = vb2_ioctl_reqbufs, .vidioc_create_bufs = vb2_ioctl_create_bufs,
@@ -418,6 +422,10 @@ static const struct v4l2_file_operations csi_fops = { .mmap = vb2_fop_mmap, }; +static const struct video_device_internal_ops csi_vdev_ops = { + .init_state = ti_csi2rx_vdev_init_state, +}; +static int csi_async_notifier_bound (struct v4l2_async_notifier *notifier,struct v4l2_subdev *subdev,struct v4l2_async_connection *asc)
@@ -518,9 +526,11 @@ static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_dev *csi)static void ti_csi2rx_setup_shim (struct ti_csi2rx_dev *csi) {const struct ti_csi2rx_fmt *fmt; +struct v4l2_format *format;unsigned int reg; - fmt =find_format_by_fourcc (csi->v_fmt.fmt.pix.pixelformat); + format =video_device_state_get_fmt (csi->vdev.state); + fmt =find_format_by_fourcc (format->fmt.pix.pixelformat);/* De-assert the pixel interface reset. */ reg =SHIM_CNTL_PIX_RST ;
@@ -671,13 +681,21 @@ static void ti_csi2rx_dma_callback(void *param)spin_unlock_irqrestore (&dma->lock, flags); } +static u32 ti_csi2rx_sizeimage (struct ti_csi2rx_dev *csi) +{ +struct v4l2_format *format = +video_device_state_get_fmt (csi->vdev.state); + +return format->fmt.pix.sizeimage; +} +static int ti_csi2rx_start_dma (struct ti_csi2rx_dev *csi,struct ti_csi2rx_buffer *buf) { -unsigned long addr;struct dma_async_tx_descriptor *desc; -size_t len = csi->v_fmt.fmt.pix.sizeimage; +unsigned long addr;dma_cookie_t cookie; +size_t len =ti_csi2rx_sizeimage (csi);int ret =0 ; addr =vb2_dma_contig_plane_dma_addr (&buf->vb.vb2_buf,0 );
@@ -754,7 +772,7 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers, struct device *alloc_devs[]) {struct ti_csi2rx_dev *csi =vb2_get_drv_priv (q); -unsigned int size = csi->v_fmt.fmt.pix.sizeimage; +unsigned int size =ti_csi2rx_sizeimage (csi);if (*nplanes) {if (sizes[0 ] < size)
@@ -771,7 +789,7 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers,static int ti_csi2rx_buffer_prepare (struct vb2_buffer *vb) {struct ti_csi2rx_dev *csi =vb2_get_drv_priv (vb->vb2_queue); -unsigned long size = csi->v_fmt.fmt.pix.sizeimage; +unsigned long size =ti_csi2rx_sizeimage (csi);if (vb2_plane_size (vb,0 ) < size) {dev_err (csi->dev,"Data will not fit into plane\n" );
@@ -951,7 +969,8 @@ static int ti_csi2rx_link_validate(struct media_link *link)struct media_entity *entity = link->sink->entity;struct video_device *vdev =media_entity_to_video_device (entity); struct ti_csi2rx_dev *csi = container_of(vdev, struct ti_csi2rx_dev, vdev); -struct v4l2_pix_format *csi_fmt = &csi->v_fmt.fmt.pix; +struct v4l2_format *format =video_device_state_get_fmt (vdev->state); +struct v4l2_pix_format *csi_fmt = &format->fmt.pix;struct v4l2_subdev_format source_fmt = { .which =V4L2_SUBDEV_FORMAT_ACTIVE , .pad = link->source->index,
@@ -1041,24 +1060,8 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) {struct media_device *mdev = &csi->mdev;struct video_device *vdev = &csi->vdev; -const struct ti_csi2rx_fmt *fmt; -struct v4l2_pix_format *pix_fmt = &csi->v_fmt.fmt.pix;int ret; - fmt =find_format_by_fourcc (V4L2_PIX_FMT_UYVY ); -if (!fmt) -return -EINVAL ; - - pix_fmt->width =640 ; - pix_fmt->height =480 ; - pix_fmt->field =V4L2_FIELD_NONE ; - pix_fmt->colorspace =V4L2_COLORSPACE_SRGB ; - pix_fmt->ycbcr_enc =V4L2_YCBCR_ENC_601 ; - pix_fmt->quantization =V4L2_QUANTIZATION_LIM_RANGE ; - pix_fmt->xfer_func =V4L2_XFER_FUNC_SRGB ; - -ti_csi2rx_fill_fmt (fmt, &csi->v_fmt); - mdev->dev = csi->dev; mdev->hw_revision =1 ;strscpy (mdev->model,"TI-CSI2RX" ,sizeof (mdev->model));
@@ -1070,10 +1073,12 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) vdev->vfl_dir =VFL_DIR_RX ; vdev->fops = &csi_fops; vdev->ioctl_ops = &csi_ioctl_ops; + vdev->vdev_ops = &csi_vdev_ops; vdev->release = video_device_release_empty; vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING |V4L2_CAP_IO_MC ; vdev->lock = &csi->mutex; +set_bit (V4L2_FL_USES_STATE , &vdev->flags);video_set_drvdata (vdev, csi); csi->pad.flags =MEDIA_PAD_FL_SINK ;
Signature · 1 line
2.51.0
Re: [PATCH v2 08/10] media: ti: j721e-csi2rx: Use video_device_state
Quoted 5 lines · Jai Luthra
Use the newly introduced
video_device_stateto store the active V4L2 format for the video device.This change allows using a single function for both .s_fmt and .try_fmt hooks, while leveraging the framework helper for the .g_fmt hook.
Rather than replying to 00/10, since that is CC-ed to a million people, I'll reply here.
For core framework changes like this I want to see it applied to the test-drivers as well. At minimum the vivid driver and, if we support this for M2M devices as well, either vim2m or vicodec.
The test-drivers are used in the media CI regression tests, so it is important that this is implemented in at least some of the test drivers.
Regards,
Hans
Quoted 246 lines
Signed-off-by Jai Luthra <[email protected]>--
Cc: Jai Luthra <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
Cc: [email protected]--- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 119 +++++++++++---------- 1 file changed, 62 insertions(+), 57 deletions(-)drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +62
-57@@ -17,6 +17,7 @@#include <media/cadence/cdns-csi2rx.h> #include <media/mipi-csi2.h> +#include <media/v4l2-dev.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-mc.h> @@ -110,7 +111,6 @@ struct ti_csi2rx_dev {struct v4l2_subdev *source;struct vb2_queue vidq;struct mutex mutex;/* To serialize ioctls. */ -struct v4l2_format v_fmt;struct ti_csi2rx_dma dma;u32 sequence;u8 pix_per_clk;@@ -308,22 +308,19 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file,return 0 ; } -static int ti_csi2rx_g_fmt_vid_cap (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct ti_csi2rx_dev *csi =video_drvdata (file); - - *f = csi->v_fmt; - -return 0 ; -} - -static int ti_csi2rx_try_fmt_vid_cap (struct file *file, +static int ti_csi2rx_adj_fmt_vid_cap (struct file *file,struct video_device_state *state,struct v4l2_format *f) {const struct ti_csi2rx_fmt *fmt; +struct v4l2_format *format; + +if (state->which ==VIDEO_DEVICE_STATE_ACTIVE ) { +struct ti_csi2rx_dev *csi =video_drvdata (file); + +if (vb2_is_busy (csi->vdev.queue)) +return -EBUSY ; + }/* * Default to the first format if the requested pixel format code isn't @@ -338,25 +335,8 @@ static int ti_csi2rx_try_fmt_vid_cap(struct file *file,ti_csi2rx_fill_fmt (fmt, f); -return 0 ; -} - -static int ti_csi2rx_s_fmt_vid_cap (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct ti_csi2rx_dev *csi =video_drvdata (file); -struct vb2_queue *q = &csi->vidq; -int ret; - -if (vb2_is_busy (q)) -return -EBUSY ; - - ret =ti_csi2rx_try_fmt_vid_cap (file, state, f); -if (ret <0 ) -return ret; - - csi->v_fmt = *f; + format =video_device_state_get_fmt (state); + *format = *f;return 0 ; }@@ -390,12 +370,36 @@ static int ti_csi2rx_enum_framesizes(struct file *file,return 0 ; } +static int ti_csi2rx_vdev_init_state (struct video_device_state *state) +{ +const struct ti_csi2rx_fmt *fmt; +struct v4l2_pix_format *pix_fmt; + + fmt =find_format_by_fourcc (V4L2_PIX_FMT_UYVY ); +if (!fmt) +return -EINVAL ; + + state->fmt.type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; + pix_fmt = &state->fmt.fmt.pix; + pix_fmt->width =640 ; + pix_fmt->height =480 ; + pix_fmt->field =V4L2_FIELD_NONE ; + pix_fmt->colorspace =V4L2_COLORSPACE_SRGB ; + pix_fmt->ycbcr_enc =V4L2_YCBCR_ENC_601 ; + pix_fmt->quantization =V4L2_QUANTIZATION_LIM_RANGE ; + pix_fmt->xfer_func =V4L2_XFER_FUNC_SRGB ; + +ti_csi2rx_fill_fmt (fmt, &state->fmt); + +return 0 ; +} +static const struct v4l2_ioctl_ops csi_ioctl_ops = { .vidioc_querycap = ti_csi2rx_querycap, .vidioc_enum_fmt_vid_cap = ti_csi2rx_enum_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = ti_csi2rx_try_fmt_vid_cap, - .vidioc_g_fmt_vid_cap = ti_csi2rx_g_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = ti_csi2rx_s_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = ti_csi2rx_adj_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = video_device_g_fmt, + .vidioc_s_fmt_vid_cap = ti_csi2rx_adj_fmt_vid_cap, .vidioc_enum_framesizes = ti_csi2rx_enum_framesizes, .vidioc_reqbufs = vb2_ioctl_reqbufs, .vidioc_create_bufs = vb2_ioctl_create_bufs,@@ -418,6 +422,10 @@ static const struct v4l2_file_operations csi_fops = { .mmap = vb2_fop_mmap, }; +static const struct video_device_internal_ops csi_vdev_ops = { + .init_state = ti_csi2rx_vdev_init_state, +}; +static int csi_async_notifier_bound (struct v4l2_async_notifier *notifier,struct v4l2_subdev *subdev,struct v4l2_async_connection *asc)@@ -518,9 +526,11 @@ static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_dev *csi)static void ti_csi2rx_setup_shim (struct ti_csi2rx_dev *csi) {const struct ti_csi2rx_fmt *fmt; +struct v4l2_format *format;unsigned int reg; - fmt =find_format_by_fourcc (csi->v_fmt.fmt.pix.pixelformat); + format =video_device_state_get_fmt (csi->vdev.state); + fmt =find_format_by_fourcc (format->fmt.pix.pixelformat);/* De-assert the pixel interface reset. */ reg =SHIM_CNTL_PIX_RST ;@@ -671,13 +681,21 @@ static void ti_csi2rx_dma_callback(void *param)spin_unlock_irqrestore (&dma->lock, flags); } +static u32 ti_csi2rx_sizeimage (struct ti_csi2rx_dev *csi) +{ +struct v4l2_format *format = +video_device_state_get_fmt (csi->vdev.state); + +return format->fmt.pix.sizeimage; +} +static int ti_csi2rx_start_dma (struct ti_csi2rx_dev *csi,struct ti_csi2rx_buffer *buf) { -unsigned long addr;struct dma_async_tx_descriptor *desc; -size_t len = csi->v_fmt.fmt.pix.sizeimage; +unsigned long addr;dma_cookie_t cookie; +size_t len =ti_csi2rx_sizeimage (csi);int ret =0 ; addr =vb2_dma_contig_plane_dma_addr (&buf->vb.vb2_buf,0 );@@ -754,7 +772,7 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers, struct device *alloc_devs[]) {struct ti_csi2rx_dev *csi =vb2_get_drv_priv (q); -unsigned int size = csi->v_fmt.fmt.pix.sizeimage; +unsigned int size =ti_csi2rx_sizeimage (csi);if (*nplanes) {if (sizes[0 ] < size)@@ -771,7 +789,7 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers,static int ti_csi2rx_buffer_prepare (struct vb2_buffer *vb) {struct ti_csi2rx_dev *csi =vb2_get_drv_priv (vb->vb2_queue); -unsigned long size = csi->v_fmt.fmt.pix.sizeimage; +unsigned long size =ti_csi2rx_sizeimage (csi);if (vb2_plane_size (vb,0 ) < size) {dev_err (csi->dev,"Data will not fit into plane\n" );@@ -951,7 +969,8 @@ static int ti_csi2rx_link_validate(struct media_link *link)struct media_entity *entity = link->sink->entity;struct video_device *vdev =media_entity_to_video_device (entity); struct ti_csi2rx_dev *csi = container_of(vdev, struct ti_csi2rx_dev, vdev); -struct v4l2_pix_format *csi_fmt = &csi->v_fmt.fmt.pix; +struct v4l2_format *format =video_device_state_get_fmt (vdev->state); +struct v4l2_pix_format *csi_fmt = &format->fmt.pix;struct v4l2_subdev_format source_fmt = { .which =V4L2_SUBDEV_FORMAT_ACTIVE , .pad = link->source->index,@@ -1041,24 +1060,8 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) {struct media_device *mdev = &csi->mdev;struct video_device *vdev = &csi->vdev; -const struct ti_csi2rx_fmt *fmt; -struct v4l2_pix_format *pix_fmt = &csi->v_fmt.fmt.pix;int ret; - fmt =find_format_by_fourcc (V4L2_PIX_FMT_UYVY ); -if (!fmt) -return -EINVAL ; - - pix_fmt->width =640 ; - pix_fmt->height =480 ; - pix_fmt->field =V4L2_FIELD_NONE ; - pix_fmt->colorspace =V4L2_COLORSPACE_SRGB ; - pix_fmt->ycbcr_enc =V4L2_YCBCR_ENC_601 ; - pix_fmt->quantization =V4L2_QUANTIZATION_LIM_RANGE ; - pix_fmt->xfer_func =V4L2_XFER_FUNC_SRGB ; - -ti_csi2rx_fill_fmt (fmt, &csi->v_fmt); - mdev->dev = csi->dev; mdev->hw_revision =1 ;strscpy (mdev->model,"TI-CSI2RX" ,sizeof (mdev->model));@@ -1070,10 +1073,12 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) vdev->vfl_dir =VFL_DIR_RX ; vdev->fops = &csi_fops; vdev->ioctl_ops = &csi_ioctl_ops; + vdev->vdev_ops = &csi_vdev_ops; vdev->release = video_device_release_empty; vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING |V4L2_CAP_IO_MC ; vdev->lock = &csi->mutex; +set_bit (V4L2_FL_USES_STATE , &vdev->flags);video_set_drvdata (vdev, csi); csi->pad.flags =MEDIA_PAD_FL_SINK ;
Re: [PATCH v2 08/10] media: ti: j721e-csi2rx: Use video_device_state
Quoting Hans Verkuil (2025-09-22 13:46:00)
Quoted 10 lines · Jai Luthra
Quoted 5 lines
Use the newly introduced
video_device_stateto store the active V4L2 format for the video device.This change allows using a single function for both .s_fmt and .try_fmt hooks, while leveraging the framework helper for the .g_fmt hook.
Rather than replying to 00/10, since that is CC-ed to a million people, I'll reply here.
Quoted 6 lines
For core framework changes like this I want to see it applied to the test-drivers as well. At minimum the vivid driver and, if we support this for M2M devices as well, either vim2m or vicodec.
The test-drivers are used in the media CI regression tests, so it is important that this is implemented in at least some of the test drivers.
Sure, will add state support to vivid in the next revision.
I'm not very familiar with M2M though, and depends on what the series looks like, but I will give that an attempt.
Quoted 5 lines
Regards,
Hans
Thanks,
Jai
[snip]
PATCH v2 9/10 media: rkisp1: Use video_device_state
In reply to Jai LuthraUse the newly introduced video_device_state to store the active V4L2 format for the video device.
Additionally, calculate stride on-demand instead of storing it in the driver context structure.
This change allows using a single function for both .s_fmt and .try_fmt hooks, while leveraging the framework helper for the .g_fmt hook.
--
Cc: Dafna Hirschfeld <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../platform/rockchip/rkisp1/rkisp1-capture.c | 135 +++++++++++---------- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 4 - 2 files changed, 70 insertions(+), 69 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +70 -65
@@ -482,7 +482,10 @@ static void rkisp1_irq_frame_end_enable(struct rkisp1_capture *cap)static void rkisp1_mp_config (struct rkisp1_capture *cap) { -const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; +u32 stride = pixm->plane_fmt[0 ].bytesperline / cap->pix.info->bpp[0 ];struct rkisp1_device *rkisp1 = cap->rkisp1;u32 reg;
@@ -494,11 +497,11 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR));if (rkisp1_has_feature (rkisp1,MAIN_STRIDE )) { -rkisp1_write (rkisp1,RKISP1_CIF_MI_MP_Y_LLENGTH , cap->stride); +rkisp1_write (rkisp1,RKISP1_CIF_MI_MP_Y_LLENGTH , stride);rkisp1_write (rkisp1,RKISP1_CIF_MI_MP_Y_PIC_WIDTH , pixm->width);rkisp1_write (rkisp1,RKISP1_CIF_MI_MP_Y_PIC_HEIGHT , pixm->height);rkisp1_write (rkisp1,RKISP1_CIF_MI_MP_Y_PIC_SIZE , - cap->stride * pixm->height); + stride * pixm->height); }rkisp1_irq_frame_end_enable (cap);
@@ -546,7 +549,10 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)static void rkisp1_sp_config (struct rkisp1_capture *cap) { -const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; +u32 stride = pixm->plane_fmt[0 ].bytesperline / cap->pix.info->bpp[0 ];struct rkisp1_device *rkisp1 = cap->rkisp1;u32 mi_ctrl, reg;
@@ -557,11 +563,11 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)rkisp1_write (rkisp1, cap->config->mi.cr_size_init,rkisp1_pixfmt_comp_size (pixm,RKISP1_PLANE_CR )); -rkisp1_write (rkisp1,RKISP1_CIF_MI_SP_Y_LLENGTH , cap->stride); +rkisp1_write (rkisp1,RKISP1_CIF_MI_SP_Y_LLENGTH , stride);rkisp1_write (rkisp1,RKISP1_CIF_MI_SP_Y_PIC_WIDTH , pixm->width);rkisp1_write (rkisp1,RKISP1_CIF_MI_SP_Y_PIC_HEIGHT , pixm->height);rkisp1_write (rkisp1,RKISP1_CIF_MI_SP_Y_PIC_SIZE , - cap->stride * pixm->height); + stride * pixm->height);rkisp1_irq_frame_end_enable (cap);
@@ -704,7 +710,9 @@ static const struct rkisp1_capture_ops rkisp1_capture_ops_sp = {static int rkisp1_dummy_buf_create (struct rkisp1_capture *cap) { -const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp;struct rkisp1_dummy_buffer *dummy_buf = &cap->buf.dummy; dummy_buf->size = max3(rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_Y),
@@ -869,7 +877,9 @@ static int rkisp1_vb2_queue_setup(struct vb2_queue *queue, struct device *alloc_devs[]) {struct rkisp1_capture *cap = queue->drv_priv; -const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp;unsigned int i;if (*num_planes) {
@@ -894,7 +904,9 @@ static int rkisp1_vb2_buf_init(struct vb2_buffer *vb)struct rkisp1_buffer *ispbuf = container_of(vbuf, struct rkisp1_buffer, vb);struct rkisp1_capture *cap = vb->vb2_queue->drv_priv; -const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp;unsigned int i;memset (ispbuf->buff_addr,0 ,sizeof (ispbuf->buff_addr));
@@ -936,10 +948,13 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)static int rkisp1_vb2_buf_prepare (struct vb2_buffer *vb) {struct rkisp1_capture *cap = vb->vb2_queue->drv_priv; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp;unsigned int i; -for (i =0 ; i < cap->pix.fmt.num_planes; i++) { -unsigned long size = cap->pix.fmt.plane_fmt[i].sizeimage; +for (i =0 ; i < pixm->num_planes; i++) { +unsigned long size = pixm->plane_fmt[i].sizeimage;if (vb2_plane_size (vb, i) < size) { dev_err(cap->rkisp1->dev,
@@ -1278,7 +1293,7 @@ rkisp1_find_fmt_cfg(const struct rkisp1_capture *cap, const u32 pixelfmt)return NULL ; } -static void rkisp1_try_fmt (const struct rkisp1_capture *cap, +static void rkisp1_adj_fmt (const struct rkisp1_capture *cap,struct v4l2_pix_format_mplane *pixm,const struct rkisp1_capture_fmt_cfg **fmt_cfg,const struct v4l2_format_info **fmt_info)
@@ -1317,23 +1332,23 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap, *fmt_info = info; } -static void rkisp1_set_fmt (struct rkisp1_capture *cap, -struct v4l2_pix_format_mplane *pixm) -{ -rkisp1_try_fmt (cap, pixm, &cap->pix.cfg, &cap->pix.info); - - cap->pix.fmt = *pixm; - cap->stride = pixm->plane_fmt[0 ].bytesperline / cap->pix.info->bpp[0 ]; -} - -static int rkisp1_try_fmt_vid_cap_mplane (struct file *file, +static int rkisp1_adj_fmt_vid_cap_mplane (struct file *file,struct video_device_state *state,struct v4l2_format *f) {struct rkisp1_capture *cap =video_drvdata (file); -rkisp1_try_fmt (cap, &f->fmt.pix_mp,NULL ,NULL ); +if (state->which ==VIDEO_DEVICE_STATE_ACTIVE ) { +if (vb2_is_busy (cap->vnode.vdev.queue)) +return -EBUSY ; +rkisp1_adj_fmt (cap, &f->fmt.pix_mp, &cap->pix.cfg, + &cap->pix.info); + }else { +rkisp1_adj_fmt (cap, &f->fmt.pix_mp,NULL ,NULL ); + } + + state->fmt = *f;return 0 ; }
@@ -1402,33 +1417,6 @@ static int rkisp1_enum_framesizes(struct file *file,return 0 ; } -static int rkisp1_s_fmt_vid_cap_mplane (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct rkisp1_capture *cap =video_drvdata (file); -struct rkisp1_vdev_node *node = -rkisp1_vdev_to_node (&cap->vnode.vdev); - -if (vb2_is_busy (&node->buf_queue)) -return -EBUSY ; - -rkisp1_set_fmt (cap, &f->fmt.pix_mp); - -return 0 ; -} - -static int rkisp1_g_fmt_vid_cap_mplane (struct file *file, -struct video_device_state *state, -struct v4l2_format *f) -{ -struct rkisp1_capture *cap =video_drvdata (file); - - f->fmt.pix_mp = cap->pix.fmt; - -return 0 ; -} -static int rkisp1_querycap (struct file *file,struct video_device_state *state,struct v4l2_capability *cap)
@@ -1450,9 +1438,9 @@ static const struct v4l2_ioctl_ops rkisp1_v4l2_ioctl_ops = { .vidioc_prepare_buf = vb2_ioctl_prepare_buf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, - .vidioc_try_fmt_vid_cap_mplane = rkisp1_try_fmt_vid_cap_mplane, - .vidioc_s_fmt_vid_cap_mplane = rkisp1_s_fmt_vid_cap_mplane, - .vidioc_g_fmt_vid_cap_mplane = rkisp1_g_fmt_vid_cap_mplane, + .vidioc_try_fmt_vid_cap_mplane = rkisp1_adj_fmt_vid_cap_mplane, + .vidioc_s_fmt_vid_cap_mplane = rkisp1_adj_fmt_vid_cap_mplane, + .vidioc_g_fmt_vid_cap_mplane = video_device_g_fmt, .vidioc_enum_fmt_vid_cap = rkisp1_enum_fmt_vid_cap_mplane, .vidioc_enum_framesizes = rkisp1_enum_framesizes, .vidioc_querycap = rkisp1_querycap,
@@ -1460,6 +1448,25 @@ static const struct v4l2_ioctl_ops rkisp1_v4l2_ioctl_ops = { .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; +static int rkisp1_vdev_init_state (struct video_device_state *state) +{ +struct rkisp1_capture *cap =video_get_drvdata (state->vdev); +struct v4l2_pix_format_mplane *pixm = &state->fmt.fmt.pix_mp; + + state->fmt.type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ; + pixm->pixelformat =V4L2_PIX_FMT_YUYV ; + pixm->width =RKISP1_DEFAULT_WIDTH ; + pixm->height =RKISP1_DEFAULT_HEIGHT ; + +rkisp1_adj_fmt (cap, pixm, &cap->pix.cfg, &cap->pix.info); + +return 0 ; +} + +static const struct video_device_internal_ops rkisp1_vdev_ops = { + .init_state = rkisp1_vdev_init_state, +}; +static int rkisp1_capture_link_validate (struct media_link *link) { struct video_device *vdev =
@@ -1467,8 +1474,11 @@ static int rkisp1_capture_link_validate(struct media_link *link)struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (link->source->entity);struct rkisp1_capture *cap =video_get_drvdata (vdev); +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp;const struct rkisp1_capture_fmt_cfg *fmt = -rkisp1_find_fmt_cfg (cap, cap->pix.fmt.pixelformat); +rkisp1_find_fmt_cfg (cap, pixm->pixelformat);struct v4l2_subdev_format sd_fmt = { .which =V4L2_SUBDEV_FORMAT_ACTIVE , .pad = link->source->index,
@@ -1479,16 +1489,16 @@ static int rkisp1_capture_link_validate(struct media_link *link)if (ret)return ret; -if (sd_fmt.format.height != cap->pix.fmt.height || - sd_fmt.format.width != cap->pix.fmt.width || +if (sd_fmt.format.height != pixm->height || + sd_fmt.format.width != pixm->width || sd_fmt.format.code != fmt->mbus) {dev_dbg (cap->rkisp1->dev,"link '%s':%u -> '%s':%u not valid: 0x%04x/%ux%u != 0x%04x/%ux%u\n" , link->source->entity->name, link->source->index, link->sink->entity->name, link->sink->index, sd_fmt.format.code, sd_fmt.format.width, - sd_fmt.format.height, fmt->mbus, cap->pix.fmt.width, - cap->pix.fmt.height); + sd_fmt.format.height, fmt->mbus, pixm->width, + pixm->height);return -EPIPE ; }
@@ -1546,6 +1556,7 @@ static int rkisp1_register_capture(struct rkisp1_capture *cap)mutex_init (&node->vlock); vdev->ioctl_ops = &rkisp1_v4l2_ioctl_ops; + vdev->vdev_ops = &rkisp1_vdev_ops; vdev->release = video_device_release_empty; vdev->fops = &rkisp1_fops; vdev->minor =-1 ;
@@ -1554,6 +1565,7 @@ static int rkisp1_register_capture(struct rkisp1_capture *cap) vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE_MPLANE |V4L2_CAP_STREAMING |V4L2_CAP_IO_MC ; vdev->entity.ops = &rkisp1_media_ops; +set_bit (V4L2_FL_USES_STATE , &vdev->flags);video_set_drvdata (vdev, cap); vdev->vfl_dir =VFL_DIR_RX ; node->pad.flags =MEDIA_PAD_FL_SINK ;
@@ -1604,7 +1616,6 @@ static void rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id) {struct rkisp1_capture *cap = &rkisp1->capture_devs[id]; -struct v4l2_pix_format_mplane pixm;memset (cap,0 ,sizeof (*cap)); cap->id = id;
@@ -1622,12 +1633,6 @@ rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id) } cap->is_streaming = false; - -memset (&pixm,0 ,sizeof (pixm)); - pixm.pixelformat =V4L2_PIX_FMT_YUYV ; - pixm.width =RKISP1_DEFAULT_WIDTH ; - pixm.height =RKISP1_DEFAULT_HEIGHT ; -rkisp1_set_fmt (cap, &pixm); }int rkisp1_capture_devs_register (struct rkisp1_device *rkisp1)
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +0 -4
@@ -309,7 +309,6 @@ struct rkisp1_device;* handler to stop the streaming by waiting on the 'done' wait queue. * If the irq handler is not called, the stream is stopped by the callback * after timeout. -* @stride: the line stride for the first plane, in pixel units * @buf.lock: lock to protect buf.queue * @buf.queue: queued buffer list * @buf.dummy: dummy space to store dropped data
@@ -319,7 +318,6 @@ struct rkisp1_device;* @buf.next: the buffer used for next frame * @pix.cfg: pixel configuration * @pix.info: a pointer to the v4l2_format_info of the pixel format -* @pix.fmt: buffer format */ struct rkisp1_capture {struct rkisp1_vdev_node vnode;
@@ -330,7 +328,6 @@ struct rkisp1_capture {bool is_streaming;bool is_stopping;wait_queue_head_t done; -unsigned int stride;struct {/* protects queue, curr and next */ spinlock_t lock;
@@ -342,7 +339,6 @@ struct rkisp1_capture {struct {const struct rkisp1_capture_fmt_cfg *cfg;const struct v4l2_format_info *info; -struct v4l2_pix_format_mplane fmt; } pix; };
Signature · 1 line
2.51.0
PATCH v2 10/10 media: rkisp1: Calculate format information on demand
In reply to Jai LuthraInstead of storing format configuration and information as explicit state in the driver structure, calculate it on demand when needed using the format stored in the active video device state.
This change removes the pix member from rkisp1_capture structure and refactors the code to look up format configuration and v4l2_format_info at the point of use.
Additionally, grey format handling is moved from the next buffer setup path (which may be called in interrupt context) to the buffer initialization phase for simplicity.
---
Cc: Dafna Hirschfeld <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../platform/rockchip/rkisp1/rkisp1-capture.c | 170 ++++++++++----------- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 6 - 2 files changed, 84 insertions(+), 92 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +84 -86
@@ -63,9 +63,12 @@ struct rkisp1_capture_fmt_cfg { };struct rkisp1_capture_ops { -void (*config)(struct rkisp1_capture *cap); +void (*config)(struct rkisp1_capture *cap, +const struct rkisp1_capture_fmt_cfg *cfg, +const struct v4l2_format_info *info);void (*stop)(struct rkisp1_capture *cap); -void (*enable)(struct rkisp1_capture *cap); +void (*enable)(struct rkisp1_capture *cap, +const struct v4l2_format_info *info);void (*disable)(struct rkisp1_capture *cap);void (*set_data_path)(struct rkisp1_capture *cap);bool (*is_stopped)(struct rkisp1_capture *cap);
@@ -480,12 +483,30 @@ static void rkisp1_irq_frame_end_enable(struct rkisp1_capture *cap)rkisp1_write (cap->rkisp1,RKISP1_CIF_MI_IMSC , mi_imsc); } -static void rkisp1_mp_config (struct rkisp1_capture *cap) +static const struct rkisp1_capture_fmt_cfg * +rkisp1_find_fmt_cfg (const struct rkisp1_capture *cap,const u32 pixelfmt) +{ +bool yc_swap_support =rkisp1_has_feature (cap->rkisp1,MAIN_STRIDE ); +unsigned int i; + +for (i =0 ; i < cap->config->fmt_size; i++) { +const struct rkisp1_capture_fmt_cfg *fmt = &cap->config->fmts[i]; + +if (fmt->fourcc == pixelfmt && + (!fmt->yc_swap || yc_swap_support)) +return &cap->config->fmts[i]; + } +return NULL ; +} + +static void rkisp1_mp_config (struct rkisp1_capture *cap, +const struct rkisp1_capture_fmt_cfg *cfg, +const struct v4l2_format_info *info) {const struct v4l2_format *format =video_device_state_get_fmt (cap->vnode.vdev.state);const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; -u32 stride = pixm->plane_fmt[0 ].bytesperline / cap->pix.info->bpp[0 ]; +u32 stride = pixm->plane_fmt[0 ].bytesperline / info->bpp[0 ];struct rkisp1_device *rkisp1 = cap->rkisp1;u32 reg;
@@ -507,9 +528,9 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)rkisp1_irq_frame_end_enable (cap);/* set uv swapping for semiplanar formats */ -if (cap->pix.info->comp_planes ==2 ) { +if (info->comp_planes ==2 ) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); -if (cap->pix.cfg->uv_swap) +if (cfg->uv_swap) reg |=RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;else reg &= ~RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP ;
@@ -523,7 +544,7 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)*/ if (rkisp1_has_feature (rkisp1,MAIN_STRIDE )) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT ); -if (cap->pix.cfg->yc_swap || cap->pix.cfg->byte_swap) +if (cfg->yc_swap || cfg->byte_swap) reg |=RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES ;else reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES ;
@@ -531,15 +552,14 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) reg |=RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_LSB_ALIGNMENT ;rkisp1_write (rkisp1,RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT , reg); -rkisp1_write (rkisp1,RKISP1_CIF_MI_INIT , - cap->pix.cfg->output_format); +rkisp1_write (rkisp1,RKISP1_CIF_MI_INIT , cfg->output_format); }rkisp1_mi_config_ctrl (cap); reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_CTRL ); reg &= ~RKISP1_MI_CTRL_MP_FMT_MASK ; - reg |= cap->pix.cfg->write_format; + reg |= cfg->write_format;rkisp1_write (rkisp1,RKISP1_CIF_MI_CTRL , reg); reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_CTRL );
@@ -547,12 +567,14 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)rkisp1_write (rkisp1,RKISP1_CIF_MI_CTRL , reg); } -static void rkisp1_sp_config (struct rkisp1_capture *cap) +static void rkisp1_sp_config (struct rkisp1_capture *cap, +const struct rkisp1_capture_fmt_cfg *cfg, +const struct v4l2_format_info *info) {const struct v4l2_format *format =video_device_state_get_fmt (cap->vnode.vdev.state);const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; -u32 stride = pixm->plane_fmt[0 ].bytesperline / cap->pix.info->bpp[0 ]; +u32 stride = pixm->plane_fmt[0 ].bytesperline / info->bpp[0 ];struct rkisp1_device *rkisp1 = cap->rkisp1;u32 mi_ctrl, reg;
@@ -572,9 +594,9 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)rkisp1_irq_frame_end_enable (cap);/* set uv swapping for semiplanar formats */ -if (cap->pix.info->comp_planes ==2 ) { +if (info->comp_planes ==2 ) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_XTD_FORMAT_CTRL ); -if (cap->pix.cfg->uv_swap) +if (cfg->uv_swap) reg |=RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ;else reg &= ~RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP ;
@@ -588,7 +610,7 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)*/ if (rkisp1_has_feature (rkisp1,MAIN_STRIDE )) { reg =rkisp1_read (rkisp1,RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT ); -if (cap->pix.cfg->yc_swap) +if (cfg->yc_swap) reg |=RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES ;else reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES ;
@@ -599,10 +621,8 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap) mi_ctrl =rkisp1_read (rkisp1,RKISP1_CIF_MI_CTRL ); mi_ctrl &= ~RKISP1_MI_CTRL_SP_FMT_MASK ; - mi_ctrl |= cap->pix.cfg->write_format | -RKISP1_MI_CTRL_SP_INPUT_YUV422 | - cap->pix.cfg->output_format | -RKISP1_CIF_MI_SP_AUTOUPDATE_ENABLE ; + mi_ctrl |= cfg->write_format |RKISP1_MI_CTRL_SP_INPUT_YUV422 | + cfg->output_format |RKISP1_CIF_MI_SP_AUTOUPDATE_ENABLE ;rkisp1_write (rkisp1,RKISP1_CIF_MI_CTRL , mi_ctrl); }
@@ -623,14 +643,15 @@ static void rkisp1_sp_disable(struct rkisp1_capture *cap)rkisp1_write (cap->rkisp1,RKISP1_CIF_MI_CTRL , mi_ctrl); } -static void rkisp1_mp_enable (struct rkisp1_capture *cap) +static void rkisp1_mp_enable (struct rkisp1_capture *cap, +const struct v4l2_format_info *info) {u32 mi_ctrl;rkisp1_mp_disable (cap); mi_ctrl =rkisp1_read (cap->rkisp1,RKISP1_CIF_MI_CTRL ); -if (v4l2_is_format_bayer (cap->pix.info)) +if (v4l2_is_format_bayer (info)) mi_ctrl |=RKISP1_CIF_MI_CTRL_RAW_ENABLE ;/* YUV */ else
@@ -639,7 +660,8 @@ static void rkisp1_mp_enable(struct rkisp1_capture *cap)rkisp1_write (cap->rkisp1,RKISP1_CIF_MI_CTRL , mi_ctrl); } -static void rkisp1_sp_enable (struct rkisp1_capture *cap) +static void rkisp1_sp_enable (struct rkisp1_capture *cap, +const struct v4l2_format_info *info) {u32 mi_ctrl =rkisp1_read (cap->rkisp1,RKISP1_CIF_MI_CTRL );
@@ -755,26 +777,12 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap)rkisp1_write (cap->rkisp1, cap->config->mi.y_base_ad_init, buff_addr[RKISP1_PLANE_Y ] >> shift); -/* -* In order to support grey format we capture -* YUV422 planar format from the camera and -* set the U and V planes to the dummy buffer -*/ -if (cap->pix.cfg->fourcc ==V4L2_PIX_FMT_GREY ) { -rkisp1_write (cap->rkisp1, - cap->config->mi.cb_base_ad_init, - cap->buf.dummy.dma_addr >> shift); -rkisp1_write (cap->rkisp1, - cap->config->mi.cr_base_ad_init, - cap->buf.dummy.dma_addr >> shift); - }else { -rkisp1_write (cap->rkisp1, - cap->config->mi.cb_base_ad_init, - buff_addr[RKISP1_PLANE_CB ] >> shift); -rkisp1_write (cap->rkisp1, - cap->config->mi.cr_base_ad_init, - buff_addr[RKISP1_PLANE_CR ] >> shift); - } +rkisp1_write (cap->rkisp1, + cap->config->mi.cb_base_ad_init, + buff_addr[RKISP1_PLANE_CB ] >> shift); +rkisp1_write (cap->rkisp1, + cap->config->mi.cr_base_ad_init, + buff_addr[RKISP1_PLANE_CR ] >> shift); }else {/* * Use the dummy space allocated by dma_alloc_coherent to
@@ -907,6 +915,10 @@ static int rkisp1_vb2_buf_init(struct vb2_buffer *vb)const struct v4l2_format *format =video_device_state_get_fmt (cap->vnode.vdev.state);const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; +const struct rkisp1_capture_fmt_cfg *cfg = +rkisp1_find_fmt_cfg (cap, pixm->pixelformat); +const struct v4l2_format_info *info = +v4l2_format_info (pixm->pixelformat);unsigned int i;memset (ispbuf->buff_addr,0 ,sizeof (ispbuf->buff_addr));
@@ -927,9 +939,19 @@ static int rkisp1_vb2_buf_init(struct vb2_buffer *vb)* uv swap can be supported for planar formats by switching * the address of cb and cr */ -if (cap->pix.info->comp_planes ==3 && cap->pix.cfg->uv_swap) +if (info->comp_planes ==3 && cfg->uv_swap)swap (ispbuf->buff_addr[RKISP1_PLANE_CR ], ispbuf->buff_addr[RKISP1_PLANE_CB ]); + +/* +* grey format can be supported by using dummy buffer for +* the cb and cr planes +*/ +if (cfg->fourcc ==V4L2_PIX_FMT_GREY ) { + ispbuf->buff_addr[RKISP1_PLANE_CB ] = cap->buf.dummy.dma_addr; + ispbuf->buff_addr[RKISP1_PLANE_CR ] = cap->buf.dummy.dma_addr; + } +return 0 ; }
@@ -1001,15 +1023,22 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap) {struct rkisp1_device *rkisp1 = cap->rkisp1;struct rkisp1_capture *other = &rkisp1->capture_devs[cap->id ^1 ]; +const struct v4l2_format *format = +video_device_state_get_fmt (cap->vnode.vdev.state); +const struct v4l2_pix_format_mplane *pixm = &format->fmt.pix_mp; +const struct rkisp1_capture_fmt_cfg *cfg = +rkisp1_find_fmt_cfg (cap, pixm->pixelformat); +const struct v4l2_format_info *info = +v4l2_format_info (pixm->pixelformat);bool has_self_path =rkisp1_has_feature (rkisp1,SELF_PATH ); cap->ops->set_data_path (cap); - cap->ops->config (cap); + cap->ops->config (cap, cfg, info);/* Setup a buffer for the next frame */ spin_lock_irq (&cap->buf.lock);rkisp1_set_next_buf (cap); - cap->ops->enable (cap); + cap->ops->enable (cap, info);/* * It's safe to configure ACTIVE and SHADOW registers for the first
@@ -1224,9 +1253,8 @@ static const struct vb2_ops rkisp1_vb2_ops = {* IOCTLs operations */ -static const struct v4l2_format_info * -rkisp1_fill_pixfmt (const struct rkisp1_capture *cap, -struct v4l2_pix_format_mplane *pixm) +static void rkisp1_fill_pixfmt (const struct rkisp1_capture *cap, +struct v4l2_pix_format_mplane *pixm) {struct v4l2_plane_pix_format *plane_y = &pixm->plane_fmt[0 ];const struct v4l2_format_info *info;
@@ -1273,34 +1301,13 @@ rkisp1_fill_pixfmt(const struct rkisp1_capture *cap,if (info->mem_planes ==1 )for (i =1 ; i < info->comp_planes; i++) plane_y->sizeimage += pixm->plane_fmt[i].sizeimage; - -return info; -} - -static const struct rkisp1_capture_fmt_cfg * -rkisp1_find_fmt_cfg (const struct rkisp1_capture *cap,const u32 pixelfmt) -{ -bool yc_swap_support =rkisp1_has_feature (cap->rkisp1,MAIN_STRIDE ); -unsigned int i; - -for (i =0 ; i < cap->config->fmt_size; i++) { -const struct rkisp1_capture_fmt_cfg *fmt = &cap->config->fmts[i]; - -if (fmt->fourcc == pixelfmt && - (!fmt->yc_swap || yc_swap_support)) -return &cap->config->fmts[i]; - } -return NULL ; }static void rkisp1_adj_fmt (const struct rkisp1_capture *cap, -struct v4l2_pix_format_mplane *pixm, -const struct rkisp1_capture_fmt_cfg **fmt_cfg, -const struct v4l2_format_info **fmt_info) +struct v4l2_pix_format_mplane *pixm) {const struct rkisp1_capture_config *config = cap->config;const struct rkisp1_capture_fmt_cfg *fmt; -const struct v4l2_format_info *info;static const unsigned int max_widths[] = {RKISP1_RSZ_MP_SRC_MAX_WIDTH ,RKISP1_RSZ_SP_SRC_MAX_WIDTH };
@@ -1324,12 +1331,7 @@ static void rkisp1_adj_fmt(const struct rkisp1_capture *cap, pixm->ycbcr_enc =V4L2_YCBCR_ENC_DEFAULT ; pixm->quantization =V4L2_QUANTIZATION_DEFAULT ; - info =rkisp1_fill_pixfmt (cap, pixm); - -if (fmt_cfg) - *fmt_cfg = fmt; -if (fmt_info) - *fmt_info = info; +rkisp1_fill_pixfmt (cap, pixm); } static int rkisp1_adj_fmt_vid_cap_mplane(struct file *file,
@@ -1338,17 +1340,13 @@ static int rkisp1_adj_fmt_vid_cap_mplane(struct file *file, {struct rkisp1_capture *cap =video_drvdata (file); -if (state->which ==VIDEO_DEVICE_STATE_ACTIVE ) { -if (vb2_is_busy (cap->vnode.vdev.queue)) -return -EBUSY ; - -rkisp1_adj_fmt (cap, &f->fmt.pix_mp, &cap->pix.cfg, - &cap->pix.info); - }else { -rkisp1_adj_fmt (cap, &f->fmt.pix_mp,NULL ,NULL ); - } +if (state->which ==VIDEO_DEVICE_STATE_ACTIVE && +vb2_is_busy (cap->vnode.vdev.queue)) +return -EBUSY ; +rkisp1_adj_fmt (cap, &f->fmt.pix_mp); state->fmt = *f; +return 0 ; }
@@ -1458,7 +1456,7 @@ static int rkisp1_vdev_init_state(struct video_device_state *state) pixm->width =RKISP1_DEFAULT_WIDTH ; pixm->height =RKISP1_DEFAULT_HEIGHT ; -rkisp1_adj_fmt (cap, pixm, &cap->pix.cfg, &cap->pix.info); +rkisp1_adj_fmt (cap, pixm);return 0 ; }
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +0 -6
@@ -316,8 +316,6 @@ struct rkisp1_device;* rkisp1 uses shadow registers, so it needs two buffers at a time * @buf.curr: the buffer used for current frame * @buf.next: the buffer used for next frame -* @pix.cfg: pixel configuration -* @pix.info: a pointer to the v4l2_format_info of the pixel format */ struct rkisp1_capture {struct rkisp1_vdev_node vnode;
@@ -336,10 +334,6 @@ struct rkisp1_capture {struct rkisp1_buffer *curr;struct rkisp1_buffer *next; } buf; -struct { -const struct rkisp1_capture_fmt_cfg *cfg; -const struct v4l2_format_info *info; - } pix; };struct rkisp1_stats ;
Signature · 1 line
2.51.0
Quoted 25 lines · Jai Luthra
Hi,
This patch series introduces state management for video devices.
Currently, V4L2 subdevices have a well-established state management system [1] that allows the framework to store the subdevice state at a central location.
Video devices however lack this, leading to inconsistent state handling across drivers and making it difficult to implement features like hardware multiplexing in complex media pipelines [2].
The series is composed of three parts:
- Core Infrastructure (PATCH 1-4)
Introduces the basic state structure, try state support, initialization callbacks, and driver helpers
- Framework Integration (PATCH 5-7)
Integrates state passing through the ioctl wrappers and driver implementations
- Driver Examples (PATCH 8-10)
Use the state to store formats in TI J721E CSI2RX and Rockchip RKISP1 drivers
Quoted 8 lines
This should also provide a foundation for drivers to extend or subclass the state structure with device-specific variables in future.
I have tested capture and format negotiation with the converted drivers on SK AM62A (j721e-csi2rx) and Debix Model A (rkisp1).
[1]: https://lore.kernel.org/linux-media/[email protected]/
[2]: https://lore.kernel.org/linux-media/20250724-multicontext-mainline-2025-v2-0-c9b316773486@ideasonboard.com/
When you add a Cc list., do it after the '---' (three minus signs) line, otherwise that huge unneeded noise will become part of the commit message.
Signature · 2 lines
With Best Regards, Andy Shevchenko