Skip to contentSkip to conversation

V4L2 subdevice query

DISCUSSION [email protected] 3 participants 3 messages Dec 19, 2011 – Jan 2, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hi

I am trying to implement a video encoder v4l2 device and need your help to find answers to some of the questions. There is one hardware core which can do multiple sessions (multiple file handles) of encode simultaneously.
The encode functionalty needs to be exposed to userspace as well as kernel through standard set of APIs. Userspace should be able to use this functionality through V4l2 interface and another kernel module should be able to use encoder as a subdevice. I am trying to explore the framework to achieve this and have following questions:

1. I am planning to create a V4L2 device and also initializing it as a subdev in the probe function i.e the probe function of this driver will have:

   struct venc_device {
                struct v4l2_device v4l2_dev;
                struct v4l2_subdev sd;

};

   struct venc_device *vdev;
   v4l2_device_register(&vdev->v4l2_dev);
   v4l2_subdev_init(&vdev->sd, venc_sd_ops);

How do other modules discover this subdevice. Is there an API I can use to find module by name?

2. Most of the subdevice interface functions have input parameters as "struct v4l2_subdev *sd" and another API specific structure. How do I distinguish between different instances (file handles) of a subdevice. Do I always need to pass file handle/instance specific information in "void *arg" of the ioctl subdev core ops.

3. Controls are instance specific, eg: one encoder application might encode at bitrate of 4Mbps and another at 128kbps, so I want controls to be specific to file handles. I see that the control handler has been moved to v4l2_fh structure for this purpose. How do I do it for
subdevices
so that the v4l2 device using this subdevice inherits the instance specific controls defined by the subdevice.

Thanks
Vinay

#1 lore raw

Hi Vinay,

Quoted 25 lines · On Monday 19 December 2011 21:08:31 [email protected] wrote:

I am trying to implement a video encoder v4l2 device and need your help to find answers to some of the questions. There is one hardware core which can do multiple sessions (multiple file handles) of encode simultaneously. The encode functionalty needs to be exposed to userspace as well as kernel through standard set of APIs. Userspace should be able to use this functionality through V4l2 interface and another kernel module should be able to use encoder as a subdevice. I am trying to explore the framework to achieve this and have following questions:

1. I am planning to create a V4L2 device and also initializing it as a subdev in the probe function i.e the probe function of this driver will have:

   struct venc_device {
                struct v4l2_device v4l2_dev;
                struct v4l2_subdev sd;
   };

   struct venc_device *vdev;
   v4l2_device_register(&vdev->v4l2_dev);
   v4l2_subdev_init(&vdev->sd, venc_sd_ops);

   How do other modules discover this subdevice. Is there an API I can use
   to find module by name?
Quoted 3 lines

2. Most of the subdevice interface functions have input parameters as "struct v4l2_subdev *sd" and another API specific structure. How do I distinguish between different instances (file handles) of a subdevice.

The short answer is that you don't.

If your hardware block can encode a fixed number of streams separately, one possible solution would be to create N subdevices, or to create a single subdevice with N input pads and N output pads, where N is the number of logical streams. Input and output pads could then be connected to video nodes or to other subdevices in the system.

Another solution is to use the mem-to-mem framework, which allows streams multiplexing through multiple opens. However, there is no clear mapping to subdevs (that I'm aware of) at the moment.

Can you share a bit more information about your hardware ? A block diagram would be useful.

Quoted 9 lines

Do I always need to pass file handle/instance specific information in "void *arg" of the ioctl subdev core ops.

3. Controls are instance specific, eg: one encoder application might encode at bitrate of 4Mbps and another at 128kbps, so I want controls to be specific to file handles. I see that the control handler has been moved to v4l2_fh structure for this purpose. How do I do it for subdevices so that the v4l2 device using this subdevice inherits the instance specific controls defined by the subdevice.

Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
In reply to [email protected]

Hi Vinay,

Quoted 12 lines · On Mon, Dec 19, 2011 at 12:08:31PM -0800, [email protected] wrote:

Hi

I am trying to implement a video encoder v4l2 device and need your help to find answers to some of the questions. There is one hardware core which can do multiple sessions (multiple file handles) of encode simultaneously.
The encode functionalty needs to be exposed to userspace as well as kernel through standard set of APIs. Userspace should be able to use this functionality through V4l2 interface and another kernel module should be able to use encoder as a subdevice. I am trying to explore the framework to achieve this and have following questions:

Is there a physical link (a bus) between the device which the another kernel module drives, and the video encoder? Memory does not count. I have never seen a video encoder which would be connected to somewhere else, e.g. an ISP.

Typically video encoders will have to access the image data in tiles that do not match with the linear read of the sensor's pixel array, which is the same order as the output of ISPs. This requires an intermediate buffer, at least, which is typically the system memory.

Any further technical information on the encoder, its connections to the rest of the SoC and the SoC itself would be helpful.

Quoted 15 lines

1. I am planning to create a V4L2 device and also initializing it as a subdev in the probe function i.e the probe function of this driver will have:

   struct venc_device {
                struct v4l2_device v4l2_dev;
                struct v4l2_subdev sd;
   };

   struct venc_device *vdev;
   v4l2_device_register(&vdev->v4l2_dev);
   v4l2_subdev_init(&vdev->sd, venc_sd_ops);

   How do other modules discover this subdevice. Is there an API
   I can use to find module by name?
Quoted 5 lines

2. Most of the subdevice interface functions have input parameters as "struct v4l2_subdev *sd" and another API specific structure. How do I distinguish between different instances (file handles) of a subdevice. Do I always need to pass file handle/instance specific information in "void *arg" of the ioctl subdev core ops.

The subdev API, as it stands currently, is intended for configuring hardware devices which only can have a single, global configuration.

If you implement your video encoder as a memory-to-memory device, I think the interface has exactly what you'll need. By default everything in memory-to-memory devices is file handle specific.

Quoted 7 lines

3. Controls are instance specific, eg: one encoder application might encode at bitrate of 4Mbps and another at 128kbps, so I want controls to be specific to file handles. I see that the control handler has been moved to v4l2_fh structure for this purpose. How do I do it for
subdevices
so that the v4l2 device using this subdevice inherits the instance specific controls defined by the subdevice.

Kind regards,

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	jabber/XMPP/Gmail: [email protected]