Skip to content

Commit 0057596

Browse files
Hans VerkuilMauro Carvalho Chehab
authored andcommitted
V4L/DVB (10988): v4l2-dev: use parent field if the v4l2_device has no parent set.
Normally the parent device of v4l2_device is used as the video device node's parent. But if it was not set, then use the parent field in the video_device struct. This is needed in the cx88 driver, which has one core v4l2_device but creates multiple pci devices (one each for raw and mpeg video). So you cannot associate the core v4l2_device with a particular PCI device, but you can do that for each video_device. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent afd9666 commit 0057596

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎Documentation/video4linux/v4l2-framework.txt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ NULL, then you *must* setup v4l2_dev->name before calling v4l2_device_register.
9191

9292
The first 'dev' argument is normally the struct device pointer of a pci_dev,
9393
usb_device or platform_device. It is rare for dev to be NULL, but it happens
94-
with ISA devices, for example.
94+
with ISA devices or when one device creates multiple PCI devices, thus making
95+
it impossible to associate v4l2_dev with a particular parent.
9596

9697
You unregister with:
9798

@@ -414,6 +415,15 @@ You should also set these fields:
414415
- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
415416
(highly recommended to use this and it might become compulsory in the
416417
future!), then set this to your v4l2_ioctl_ops struct.
418+
- parent: you only set this if v4l2_device was registered with NULL as
419+
the parent device struct. This only happens in cases where one hardware
420+
device has multiple PCI devices that all share the same v4l2_device core.
421+
422+
The cx88 driver is an example of this: one core v4l2_device struct, but
423+
it is used by both an raw video PCI device (cx8800) and a MPEG PCI device
424+
(cx8802). Since the v4l2_device cannot be associated with a particular
425+
PCI device it is setup without a parent device. But when the struct
426+
video_device is setup you do know which parent PCI device to use.
417427

418428
If you use v4l2_ioctl_ops, then you should set either .unlocked_ioctl or
419429
.ioctl to video_ioctl2 in your v4l2_file_operations struct.

‎drivers/media/video/v4l2-dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ int video_register_device_index(struct video_device *vdev, int type, int nr,
395395

396396
vdev->vfl_type = type;
397397
vdev->cdev = NULL;
398-
if (vdev->v4l2_dev)
398+
if (vdev->v4l2_dev && vdev->v4l2_dev->dev)
399399
vdev->parent = vdev->v4l2_dev->dev;
400400

401401
/* Part 2: find a free minor, kernel number and device index. */

0 commit comments

Comments
 (0)