xref: /linux/Documentation/driver-api/media/mc-core.rst (revision c771600c6af14749609b49565ffb4cac2959710d)
1f2ac8ce8SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2f2ac8ce8SMauro Carvalho Chehab
3684ffa2dSMauro Carvalho ChehabMedia Controller devices
4684ffa2dSMauro Carvalho Chehab------------------------
5684ffa2dSMauro Carvalho Chehab
6684ffa2dSMauro Carvalho ChehabMedia Controller
7684ffa2dSMauro Carvalho Chehab~~~~~~~~~~~~~~~~
8684ffa2dSMauro Carvalho Chehab
974604b73SMauro Carvalho ChehabThe media controller userspace API is documented in
10da83c888SMauro Carvalho Chehab:ref:`the Media Controller uAPI book <media_controller>`. This document focus
11684ffa2dSMauro Carvalho Chehabon the kernel-side implementation of the media framework.
12684ffa2dSMauro Carvalho Chehab
13684ffa2dSMauro Carvalho ChehabAbstract media device model
14684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^
15684ffa2dSMauro Carvalho Chehab
16684ffa2dSMauro Carvalho ChehabDiscovering a device internal topology, and configuring it at runtime, is one
17684ffa2dSMauro Carvalho Chehabof the goals of the media framework. To achieve this, hardware devices are
18684ffa2dSMauro Carvalho Chehabmodelled as an oriented graph of building blocks called entities connected
19684ffa2dSMauro Carvalho Chehabthrough pads.
20684ffa2dSMauro Carvalho Chehab
21684ffa2dSMauro Carvalho ChehabAn entity is a basic media hardware building block. It can correspond to
22684ffa2dSMauro Carvalho Chehaba large variety of logical blocks such as physical hardware devices
23684ffa2dSMauro Carvalho Chehab(CMOS sensor for instance), logical hardware devices (a building block
24684ffa2dSMauro Carvalho Chehabin a System-on-Chip image processing pipeline), DMA channels or physical
25684ffa2dSMauro Carvalho Chehabconnectors.
26684ffa2dSMauro Carvalho Chehab
27684ffa2dSMauro Carvalho ChehabA pad is a connection endpoint through which an entity can interact with
28684ffa2dSMauro Carvalho Chehabother entities. Data (not restricted to video) produced by an entity
29684ffa2dSMauro Carvalho Chehabflows from the entity's output to one or more entity inputs. Pads should
30684ffa2dSMauro Carvalho Chehabnot be confused with physical pins at chip boundaries.
31684ffa2dSMauro Carvalho Chehab
32684ffa2dSMauro Carvalho ChehabA link is a point-to-point oriented connection between two pads, either
33684ffa2dSMauro Carvalho Chehabon the same entity or on different entities. Data flows from a source
34684ffa2dSMauro Carvalho Chehabpad to a sink pad.
35684ffa2dSMauro Carvalho Chehab
36684ffa2dSMauro Carvalho ChehabMedia device
37684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^
38684ffa2dSMauro Carvalho Chehab
399303c9d5SMauro Carvalho ChehabA media device is represented by a struct media_device
4074604b73SMauro Carvalho Chehabinstance, defined in ``include/media/media-device.h``.
4174604b73SMauro Carvalho ChehabAllocation of the structure is handled by the media device driver, usually by
4274604b73SMauro Carvalho Chehabembedding the :c:type:`media_device` instance in a larger driver-specific
4374604b73SMauro Carvalho Chehabstructure.
44684ffa2dSMauro Carvalho Chehab
451d1d8669SSakari AilusDrivers initialise media device instances by calling
461d1d8669SSakari Ailus:c:func:`media_device_init()`. After initialising a media device instance, it is
471d1d8669SSakari Ailusregistered by calling :c:func:`__media_device_register()` via the macro
481d1d8669SSakari Ailus``media_device_register()`` and unregistered by calling
491d1d8669SSakari Ailus:c:func:`media_device_unregister()`. An initialised media device must be
501d1d8669SSakari Ailuseventually cleaned up by calling :c:func:`media_device_cleanup()`.
511d1d8669SSakari Ailus
521d1d8669SSakari AilusNote that it is not allowed to unregister a media device instance that was not
531d1d8669SSakari Ailuspreviously registered, or clean up a media device instance that was not
541d1d8669SSakari Ailuspreviously initialised.
55684ffa2dSMauro Carvalho Chehab
56684ffa2dSMauro Carvalho ChehabEntities
57684ffa2dSMauro Carvalho Chehab^^^^^^^^
58684ffa2dSMauro Carvalho Chehab
599303c9d5SMauro Carvalho ChehabEntities are represented by a struct media_entity
6074604b73SMauro Carvalho Chehabinstance, defined in ``include/media/media-entity.h``. The structure is usually
6174604b73SMauro Carvalho Chehabembedded into a higher-level structure, such as
62041d8211SMauro Carvalho Chehab:c:type:`v4l2_subdev` or :c:type:`video_device`
6374604b73SMauro Carvalho Chehabinstances, although drivers can allocate entities directly.
64684ffa2dSMauro Carvalho Chehab
65684ffa2dSMauro Carvalho ChehabDrivers initialize entity pads by calling
667b998baeSMauro Carvalho Chehab:c:func:`media_entity_pads_init()`.
67684ffa2dSMauro Carvalho Chehab
68684ffa2dSMauro Carvalho ChehabDrivers register entities with a media device by calling
697b998baeSMauro Carvalho Chehab:c:func:`media_device_register_entity()`
70adf48e3fSMauro Carvalho Chehaband unregistered by calling
717b998baeSMauro Carvalho Chehab:c:func:`media_device_unregister_entity()`.
72684ffa2dSMauro Carvalho Chehab
73684ffa2dSMauro Carvalho ChehabInterfaces
74684ffa2dSMauro Carvalho Chehab^^^^^^^^^^
75684ffa2dSMauro Carvalho Chehab
7674604b73SMauro Carvalho ChehabInterfaces are represented by a
779303c9d5SMauro Carvalho Chehabstruct media_interface instance, defined in
7874604b73SMauro Carvalho Chehab``include/media/media-entity.h``. Currently, only one type of interface is
7974604b73SMauro Carvalho Chehabdefined: a device node. Such interfaces are represented by a
809303c9d5SMauro Carvalho Chehabstruct media_intf_devnode.
81684ffa2dSMauro Carvalho Chehab
82684ffa2dSMauro Carvalho ChehabDrivers initialize and create device node interfaces by calling
837b998baeSMauro Carvalho Chehab:c:func:`media_devnode_create()`
84684ffa2dSMauro Carvalho Chehaband remove them by calling:
857b998baeSMauro Carvalho Chehab:c:func:`media_devnode_remove()`.
86684ffa2dSMauro Carvalho Chehab
87684ffa2dSMauro Carvalho ChehabPads
88684ffa2dSMauro Carvalho Chehab^^^^
899303c9d5SMauro Carvalho ChehabPads are represented by a struct media_pad instance,
9074604b73SMauro Carvalho Chehabdefined in ``include/media/media-entity.h``. Each entity stores its pads in
9174604b73SMauro Carvalho Chehaba pads array managed by the entity driver. Drivers usually embed the array in
9274604b73SMauro Carvalho Chehaba driver-specific structure.
93684ffa2dSMauro Carvalho Chehab
94684ffa2dSMauro Carvalho ChehabPads are identified by their entity and their 0-based index in the pads
95684ffa2dSMauro Carvalho Chehabarray.
9674604b73SMauro Carvalho Chehab
979303c9d5SMauro Carvalho ChehabBoth information are stored in the struct media_pad,
989303c9d5SMauro Carvalho Chehabmaking the struct media_pad pointer the canonical way
993c7d91efSMauro Carvalho Chehabto store and pass link references.
100684ffa2dSMauro Carvalho Chehab
101684ffa2dSMauro Carvalho ChehabPads have flags that describe the pad capabilities and state.
102684ffa2dSMauro Carvalho Chehab
10374604b73SMauro Carvalho Chehab``MEDIA_PAD_FL_SINK`` indicates that the pad supports sinking data.
10474604b73SMauro Carvalho Chehab``MEDIA_PAD_FL_SOURCE`` indicates that the pad supports sourcing data.
105684ffa2dSMauro Carvalho Chehab
10674604b73SMauro Carvalho Chehab.. note::
10774604b73SMauro Carvalho Chehab
10874604b73SMauro Carvalho Chehab  One and only one of ``MEDIA_PAD_FL_SINK`` or ``MEDIA_PAD_FL_SOURCE`` must
109684ffa2dSMauro Carvalho Chehab  be set for each pad.
110684ffa2dSMauro Carvalho Chehab
111684ffa2dSMauro Carvalho ChehabLinks
112684ffa2dSMauro Carvalho Chehab^^^^^
113684ffa2dSMauro Carvalho Chehab
1149303c9d5SMauro Carvalho ChehabLinks are represented by a struct media_link instance,
11574604b73SMauro Carvalho Chehabdefined in ``include/media/media-entity.h``. There are two types of links:
116684ffa2dSMauro Carvalho Chehab
11774604b73SMauro Carvalho Chehab**1. pad to pad links**:
118684ffa2dSMauro Carvalho Chehab
119684ffa2dSMauro Carvalho ChehabAssociate two entities via their PADs. Each entity has a list that points
120684ffa2dSMauro Carvalho Chehabto all links originating at or targeting any of its pads.
121684ffa2dSMauro Carvalho ChehabA given link is thus stored twice, once in the source entity and once in
122684ffa2dSMauro Carvalho Chehabthe target entity.
123684ffa2dSMauro Carvalho Chehab
124684ffa2dSMauro Carvalho ChehabDrivers create pad to pad links by calling:
1257b998baeSMauro Carvalho Chehab:c:func:`media_create_pad_link()` and remove with
1267b998baeSMauro Carvalho Chehab:c:func:`media_entity_remove_links()`.
127684ffa2dSMauro Carvalho Chehab
12874604b73SMauro Carvalho Chehab**2. interface to entity links**:
129684ffa2dSMauro Carvalho Chehab
130684ffa2dSMauro Carvalho ChehabAssociate one interface to a Link.
131684ffa2dSMauro Carvalho Chehab
132684ffa2dSMauro Carvalho ChehabDrivers create interface to entity links by calling:
1337b998baeSMauro Carvalho Chehab:c:func:`media_create_intf_link()` and remove with
1347b998baeSMauro Carvalho Chehab:c:func:`media_remove_intf_links()`.
135684ffa2dSMauro Carvalho Chehab
136684ffa2dSMauro Carvalho Chehab.. note::
137684ffa2dSMauro Carvalho Chehab
138684ffa2dSMauro Carvalho Chehab   Links can only be created after having both ends already created.
139684ffa2dSMauro Carvalho Chehab
140684ffa2dSMauro Carvalho ChehabLinks have flags that describe the link capabilities and state. The
1417b998baeSMauro Carvalho Chehabvalid values are described at :c:func:`media_create_pad_link()` and
1427b998baeSMauro Carvalho Chehab:c:func:`media_create_intf_link()`.
143684ffa2dSMauro Carvalho Chehab
144684ffa2dSMauro Carvalho ChehabGraph traversal
145684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^^^^
146684ffa2dSMauro Carvalho Chehab
1476c573f25SLaurent PinchartThe media framework provides APIs to traverse media graphs, locating connected
1486c573f25SLaurent Pinchartentities and links.
149684ffa2dSMauro Carvalho Chehab
150684ffa2dSMauro Carvalho ChehabTo iterate over all entities belonging to a media device, drivers can use
151684ffa2dSMauro Carvalho Chehabthe media_device_for_each_entity macro, defined in
15274604b73SMauro Carvalho Chehab``include/media/media-device.h``.
15374604b73SMauro Carvalho Chehab
15474604b73SMauro Carvalho Chehab..  code-block:: c
155684ffa2dSMauro Carvalho Chehab
156684ffa2dSMauro Carvalho Chehab    struct media_entity *entity;
157684ffa2dSMauro Carvalho Chehab
158684ffa2dSMauro Carvalho Chehab    media_device_for_each_entity(entity, mdev) {
159684ffa2dSMauro Carvalho Chehab    // entity will point to each entity in turn
160684ffa2dSMauro Carvalho Chehab    ...
161684ffa2dSMauro Carvalho Chehab    }
162684ffa2dSMauro Carvalho Chehab
163684ffa2dSMauro Carvalho ChehabHelper functions can be used to find a link between two given pads, or a pad
164684ffa2dSMauro Carvalho Chehabconnected to another pad through an enabled link
165bb85604bSLaurent Pinchart(:c:func:`media_entity_find_link()`, :c:func:`media_pad_remote_pad_first()`,
16603b28286SLaurent Pinchart:c:func:`media_entity_remote_source_pad_unique()` and
16703b28286SLaurent Pinchart:c:func:`media_pad_remote_pad_unique()`).
168684ffa2dSMauro Carvalho Chehab
169684ffa2dSMauro Carvalho ChehabUse count and power handling
170684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171684ffa2dSMauro Carvalho Chehab
172684ffa2dSMauro Carvalho ChehabDue to the wide differences between drivers regarding power management
173684ffa2dSMauro Carvalho Chehabneeds, the media controller does not implement power management. However,
1749303c9d5SMauro Carvalho Chehabthe struct media_entity includes a ``use_count``
17574604b73SMauro Carvalho Chehabfield that media drivers
176684ffa2dSMauro Carvalho Chehabcan use to track the number of users of every entity for power management
177684ffa2dSMauro Carvalho Chehabneeds.
178684ffa2dSMauro Carvalho Chehab
17974604b73SMauro Carvalho ChehabThe :c:type:`media_entity<media_entity>`.\ ``use_count`` field is owned by
18074604b73SMauro Carvalho Chehabmedia drivers and must not be
181684ffa2dSMauro Carvalho Chehabtouched by entity drivers. Access to the field must be protected by the
18274604b73SMauro Carvalho Chehab:c:type:`media_device`.\ ``graph_mutex`` lock.
183684ffa2dSMauro Carvalho Chehab
184684ffa2dSMauro Carvalho ChehabLinks setup
185684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^
186684ffa2dSMauro Carvalho Chehab
187684ffa2dSMauro Carvalho ChehabLink properties can be modified at runtime by calling
1887b998baeSMauro Carvalho Chehab:c:func:`media_entity_setup_link()`.
189684ffa2dSMauro Carvalho Chehab
190684ffa2dSMauro Carvalho ChehabPipelines and media streams
191684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^
192684ffa2dSMauro Carvalho Chehab
193b558ce56STomi ValkeinenA media stream is a stream of pixels or metadata originating from one or more
194b558ce56STomi Valkeinensource devices (such as a sensors) and flowing through media entity pads
195b558ce56STomi Valkeinentowards the final sinks. The stream can be modified on the route by the
196b558ce56STomi Valkeinendevices (e.g. scaling or pixel format conversions), or it can be split into
197b558ce56STomi Valkeinenmultiple branches, or multiple branches can be merged.
198b558ce56STomi Valkeinen
199b558ce56STomi ValkeinenA media pipeline is a set of media streams which are interdependent. This
200b558ce56STomi Valkeineninterdependency can be caused by the hardware (e.g. configuration of a second
201b558ce56STomi Valkeinenstream cannot be changed if the first stream has been enabled) or by the driver
202b558ce56STomi Valkeinendue to the software design. Most commonly a media pipeline consists of a single
203b558ce56STomi Valkeinenstream which does not branch.
204b558ce56STomi Valkeinen
205684ffa2dSMauro Carvalho ChehabWhen starting streaming, drivers must notify all entities in the pipeline to
206684ffa2dSMauro Carvalho Chehabprevent link states from being modified during streaming by calling
20720b85227SSakari Ailus:c:func:`media_pipeline_start()`.
208684ffa2dSMauro Carvalho Chehab
209ae219872SLaurent PinchartThe function will mark all the pads which are part of the pipeline as streaming.
210684ffa2dSMauro Carvalho Chehab
211b5163545SLaurent PinchartThe struct media_pipeline instance pointed to by the pipe argument will be
212b5163545SLaurent Pinchartstored in every pad in the pipeline. Drivers should embed the struct
213b5163545SLaurent Pinchartmedia_pipeline in higher-level pipeline structures and can then access the
214b5163545SLaurent Pinchartpipeline through the struct media_pad pipe field.
215684ffa2dSMauro Carvalho Chehab
21620b85227SSakari AilusCalls to :c:func:`media_pipeline_start()` can be nested.
21774604b73SMauro Carvalho ChehabThe pipeline pointer must be identical for all nested calls to the function.
218684ffa2dSMauro Carvalho Chehab
21920b85227SSakari Ailus:c:func:`media_pipeline_start()` may return an error. In that case,
22074604b73SMauro Carvalho Chehabit will clean up any of the changes it did by itself.
221684ffa2dSMauro Carvalho Chehab
222684ffa2dSMauro Carvalho ChehabWhen stopping the stream, drivers must notify the entities with
22320b85227SSakari Ailus:c:func:`media_pipeline_stop()`.
224684ffa2dSMauro Carvalho Chehab
22520b85227SSakari AilusIf multiple calls to :c:func:`media_pipeline_start()` have been
22620b85227SSakari Ailusmade the same number of :c:func:`media_pipeline_stop()` calls
22774604b73SMauro Carvalho Chehabare required to stop streaming.
22874604b73SMauro Carvalho ChehabThe :c:type:`media_entity`.\ ``pipe`` field is reset to ``NULL`` on the last
22974604b73SMauro Carvalho Chehabnested stop call.
230684ffa2dSMauro Carvalho Chehab
23174604b73SMauro Carvalho ChehabLink configuration will fail with ``-EBUSY`` by default if either end of the
232684ffa2dSMauro Carvalho Chehablink is a streaming entity. Links that can be modified while streaming must
23374604b73SMauro Carvalho Chehabbe marked with the ``MEDIA_LNK_FL_DYNAMIC`` flag.
234684ffa2dSMauro Carvalho Chehab
235684ffa2dSMauro Carvalho ChehabIf other operations need to be disallowed on streaming entities (such as
236684ffa2dSMauro Carvalho Chehabchanging entities configuration parameters) drivers can explicitly check the
237684ffa2dSMauro Carvalho Chehabmedia_entity stream_count field to find out if an entity is streaming. This
238684ffa2dSMauro Carvalho Chehaboperation must be done with the media_device graph_mutex held.
239684ffa2dSMauro Carvalho Chehab
240684ffa2dSMauro Carvalho ChehabLink validation
241684ffa2dSMauro Carvalho Chehab^^^^^^^^^^^^^^^
242684ffa2dSMauro Carvalho Chehab
24320b85227SSakari AilusLink validation is performed by :c:func:`media_pipeline_start()`
24474604b73SMauro Carvalho Chehabfor any entity which has sink pads in the pipeline. The
24574604b73SMauro Carvalho Chehab:c:type:`media_entity`.\ ``link_validate()`` callback is used for that
24674604b73SMauro Carvalho Chehabpurpose. In ``link_validate()`` callback, entity driver should check
24774604b73SMauro Carvalho Chehabthat the properties of the source pad of the connected entity and its own
24874604b73SMauro Carvalho Chehabsink pad match. It is up to the type of the entity (and in the end, the
24974604b73SMauro Carvalho Chehabproperties of the hardware) what matching actually means.
250684ffa2dSMauro Carvalho Chehab
251684ffa2dSMauro Carvalho ChehabSubsystems should facilitate link validation by providing subsystem specific
252684ffa2dSMauro Carvalho Chehabhelper functions to provide easy access for commonly needed information, and
253684ffa2dSMauro Carvalho Chehabin the end provide a way to use driver-specific callbacks.
254684ffa2dSMauro Carvalho Chehab
2556c573f25SLaurent PinchartPipeline traversal
2566c573f25SLaurent Pinchart^^^^^^^^^^^^^^^^^^
2576c573f25SLaurent Pinchart
2586c573f25SLaurent PinchartOnce a pipeline has been constructed with :c:func:`media_pipeline_start()`,
2596c573f25SLaurent Pinchartdrivers can iterate over entities or pads in the pipeline with the
2606c573f25SLaurent Pinchart:c:macro:´media_pipeline_for_each_entity` and
2616c573f25SLaurent Pinchart:c:macro:´media_pipeline_for_each_pad` macros. Iterating over pads is
2626c573f25SLaurent Pinchartstraightforward:
2636c573f25SLaurent Pinchart
2646c573f25SLaurent Pinchart.. code-block:: c
2656c573f25SLaurent Pinchart
2666c573f25SLaurent Pinchart   media_pipeline_pad_iter iter;
2676c573f25SLaurent Pinchart   struct media_pad *pad;
2686c573f25SLaurent Pinchart
2696c573f25SLaurent Pinchart   media_pipeline_for_each_pad(pipe, &iter, pad) {
2706c573f25SLaurent Pinchart       /* 'pad' will point to each pad in turn */
2716c573f25SLaurent Pinchart       ...
2726c573f25SLaurent Pinchart   }
2736c573f25SLaurent Pinchart
2746c573f25SLaurent PinchartTo iterate over entities, the iterator needs to be initialized and cleaned up
2756c573f25SLaurent Pinchartas an additional steps:
2766c573f25SLaurent Pinchart
2776c573f25SLaurent Pinchart.. code-block:: c
2786c573f25SLaurent Pinchart
2796c573f25SLaurent Pinchart   media_pipeline_entity_iter iter;
2806c573f25SLaurent Pinchart   struct media_entity *entity;
2816c573f25SLaurent Pinchart   int ret;
2826c573f25SLaurent Pinchart
2836c573f25SLaurent Pinchart   ret = media_pipeline_entity_iter_init(pipe, &iter);
2846c573f25SLaurent Pinchart   if (ret)
2856c573f25SLaurent Pinchart       ...;
2866c573f25SLaurent Pinchart
2876c573f25SLaurent Pinchart   media_pipeline_for_each_entity(pipe, &iter, entity) {
2886c573f25SLaurent Pinchart       /* 'entity' will point to each entity in turn */
2896c573f25SLaurent Pinchart       ...
2906c573f25SLaurent Pinchart   }
2916c573f25SLaurent Pinchart
2926c573f25SLaurent Pinchart   media_pipeline_entity_iter_cleanup(&iter);
2936c573f25SLaurent Pinchart
2946e1d824eSShuah KhanMedia Controller Device Allocator API
2956e1d824eSShuah Khan^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2966e1d824eSShuah Khan
2976e1d824eSShuah KhanWhen the media device belongs to more than one driver, the shared media
2986e1d824eSShuah Khandevice is allocated with the shared struct device as the key for look ups.
2996e1d824eSShuah Khan
3006e1d824eSShuah KhanThe shared media device should stay in registered state until the last
3016e1d824eSShuah Khandriver unregisters it. In addition, the media device should be released when
3026e1d824eSShuah Khanall the references are released. Each driver gets a reference to the media
3036e1d824eSShuah Khandevice during probe, when it allocates the media device. If media device is
3046e1d824eSShuah Khanalready allocated, the allocate API bumps up the refcount and returns the
3056e1d824eSShuah Khanexisting media device. The driver puts the reference back in its disconnect
3066e1d824eSShuah Khanroutine when it calls :c:func:`media_device_delete()`.
3076e1d824eSShuah Khan
3086e1d824eSShuah KhanThe media device is unregistered and cleaned up from the kref put handler to
3096e1d824eSShuah Khanensure that the media device stays in registered state until the last driver
3106e1d824eSShuah Khanunregisters the media device.
3116e1d824eSShuah Khan
3126e1d824eSShuah Khan**Driver Usage**
3136e1d824eSShuah Khan
3146e1d824eSShuah KhanDrivers should use the appropriate media-core routines to manage the shared
3156e1d824eSShuah Khanmedia device life-time handling the two states:
3166e1d824eSShuah Khan1. allocate -> register -> delete
3176e1d824eSShuah Khan2. get reference to already registered device -> delete
3186e1d824eSShuah Khan
3196e1d824eSShuah Khancall :c:func:`media_device_delete()` routine to make sure the shared media
3206e1d824eSShuah Khandevice delete is handled correctly.
3216e1d824eSShuah Khan
3226e1d824eSShuah Khan**driver probe:**
3236e1d824eSShuah KhanCall :c:func:`media_device_usb_allocate()` to allocate or get a reference
3246e1d824eSShuah KhanCall :c:func:`media_device_register()`, if media devnode isn't registered
3256e1d824eSShuah Khan
3266e1d824eSShuah Khan**driver disconnect:**
3276e1d824eSShuah KhanCall :c:func:`media_device_delete()` to free the media_device. Freeing is
3286e1d824eSShuah Khanhandled by the kref put handler.
3296e1d824eSShuah Khan
3306e1d824eSShuah KhanAPI Definitions
3316e1d824eSShuah Khan^^^^^^^^^^^^^^^
3326e1d824eSShuah Khan
333684ffa2dSMauro Carvalho Chehab.. kernel-doc:: include/media/media-device.h
334684ffa2dSMauro Carvalho Chehab
335684ffa2dSMauro Carvalho Chehab.. kernel-doc:: include/media/media-devnode.h
336684ffa2dSMauro Carvalho Chehab
337684ffa2dSMauro Carvalho Chehab.. kernel-doc:: include/media/media-entity.h
338496f6f4dSSakari Ailus
339496f6f4dSSakari Ailus.. kernel-doc:: include/media/media-request.h
3406e1d824eSShuah Khan
3416e1d824eSShuah Khan.. kernel-doc:: include/media/media-dev-allocator.h
342