Documentation/driver-api/media/v4l2-fh.rst

Source file repositories/reference/linux-study-clean/Documentation/driver-api/media/v4l2-fh.rst

File Facts

System
Linux kernel
Corpus path
Documentation/driver-api/media/v4l2-fh.rst
Extension
.rst
Size
3920 bytes
Lines
137
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct my_fh {
		int blah;
		struct v4l2_fh fh;
	};

	...

	int my_open(struct file *file)
	{
		struct my_fh *my_fh;
		struct video_device *vfd;
		int ret;

		...

		my_fh = kzalloc_obj(*my_fh);

		...

		v4l2_fh_init(&my_fh->fh, vfd);

		...

		v4l2_fh_add(&my_fh->fh, file);
		return 0;
	}

	int my_release(struct file *file)
	{
		struct v4l2_fh *fh = file_to_v4l2_fh(file);
		struct my_fh *my_fh = container_of(fh, struct my_fh, fh);

		...
		v4l2_fh_del(&my_fh->fh, file);
		v4l2_fh_exit(&my_fh->fh);
		kfree(my_fh);
		return 0;
	}

Below is a short description of the :c:type:`v4l2_fh` functions used:

:c:func:`v4l2_fh_init <v4l2_fh_init>`
(:c:type:`fh <v4l2_fh>`, :c:type:`vdev <video_device>`)

- Initialise the file handle. This **MUST** be performed in the driver's
  :c:type:`v4l2_file_operations`->open() handler.

:c:func:`v4l2_fh_add <v4l2_fh_add>`
(:c:type:`fh <v4l2_fh>`, struct file \*filp)

- Add a :c:type:`v4l2_fh` to :c:type:`video_device` file handle list.
  Must be called once the file handle is completely initialized.

:c:func:`v4l2_fh_del <v4l2_fh_del>`
(:c:type:`fh <v4l2_fh>`, struct file \*filp)

- Unassociate the file handle from :c:type:`video_device`. The file handle
  exit function may now be called.

:c:func:`v4l2_fh_exit <v4l2_fh_exit>`
(:c:type:`fh <v4l2_fh>`)

- Uninitialise the file handle. After uninitialisation the :c:type:`v4l2_fh`
  memory can be freed.

:c:func:`file_to_v4l2_fh <file_to_v4l2_fh>`
(struct file \*filp)

- Retrieve the :c:type:`v4l2_fh` instance associated with a :c:type:`file`.

Annotation

Implementation Notes