]>
git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - include/media/media-dev-allocator.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * media-dev-allocator.h - Media Controller Device Allocator API
5 * Copyright (c) 2019 Shuah Khan <shuah@kernel.org>
7 * Credits: Suggested by Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 * This file adds a global ref-counted Media Controller Device Instance API.
12 * A system wide global media device list is managed and each media device
13 * includes a kref count. The last put on the media device releases the media
17 #ifndef _MEDIA_DEV_ALLOCATOR_H
18 #define _MEDIA_DEV_ALLOCATOR_H
22 #if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB)
24 * media_device_usb_allocate() - Allocate and return struct &media device
26 * @udev: struct &usb_device pointer
27 * @module_name: should be filled with %KBUILD_MODNAME
28 * @owner: struct module pointer %THIS_MODULE for the driver.
29 * %THIS_MODULE is null for a built-in driver.
30 * It is safe even when %THIS_MODULE is null.
32 * This interface should be called to allocate a Media Device when multiple
33 * drivers share usb_device and the media device. This interface allocates
34 * &media_device structure and calls media_device_usb_init() to initialize
38 struct media_device
*media_device_usb_allocate(struct usb_device
*udev
,
39 const char *module_name
,
40 struct module
*owner
);
42 * media_device_delete() - Release media device. Calls kref_put().
44 * @mdev: struct &media_device pointer
45 * @module_name: should be filled with %KBUILD_MODNAME
46 * @owner: struct module pointer %THIS_MODULE for the driver.
47 * %THIS_MODULE is null for a built-in driver.
48 * It is safe even when %THIS_MODULE is null.
50 * This interface should be called to put Media Device Instance kref.
52 void media_device_delete(struct media_device
*mdev
, const char *module_name
,
53 struct module
*owner
);
55 static inline struct media_device
*media_device_usb_allocate(
56 struct usb_device
*udev
, const char *module_name
,
59 static inline void media_device_delete(
60 struct media_device
*mdev
, const char *module_name
,
61 struct module
*owner
) { }
62 #endif /* CONFIG_MEDIA_CONTROLLER && CONFIG_USB */
63 #endif /* _MEDIA_DEV_ALLOCATOR_H */