^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010 Nokia Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Sakari Ailus <sakari.ailus@iki.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifndef _MEDIA_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define _MEDIA_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <media/media-devnode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <media/media-entity.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct ida;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct media_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * struct media_entity_notify - Media Entity Notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * @list: List head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @notify_data: Input data to invoke the callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @notify: Callback function pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Drivers may register a callback to take action when new entities get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * registered with the media device. This handler is intended for creating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * links between existing entities and should not create entities and register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct media_entity_notify {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void *notify_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void (*notify)(struct media_entity *entity, void *notify_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * struct media_device_ops - Media device operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @link_notify: Link state change notification callback. This callback is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * called with the graph_mutex held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @req_alloc: Allocate a request. Set this if you need to allocate a struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * larger then struct media_request. @req_alloc and @req_free must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * either both be set or both be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @req_free: Free a request. Set this if @req_alloc was set as well, leave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * to NULL otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @req_validate: Validate a request, but do not queue yet. The req_queue_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * lock is held when this op is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @req_queue: Queue a validated request, cannot fail. If something goes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * wrong when queueing this request then it should be marked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * as such internally in the driver and any related buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * must eventually return to vb2 with state VB2_BUF_STATE_ERROR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * The req_queue_mutex lock is held when this op is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * It is important that vb2 buffer objects are queued last after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * all other object types are queued: queueing a buffer kickstarts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * the request processing, so all other objects related to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * request (and thus the buffer) must be available to the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * And once a buffer is queued, then the driver can complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * or delete objects from the request before req_queue exits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct media_device_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int (*link_notify)(struct media_link *link, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned int notification);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct media_request *(*req_alloc)(struct media_device *mdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void (*req_free)(struct media_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int (*req_validate)(struct media_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void (*req_queue)(struct media_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * struct media_device - Media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @dev: Parent device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @devnode: Media device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * @driver_name: Optional device driver name. If not set, calls to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * %MEDIA_IOC_DEVICE_INFO will return ``dev->driver->name``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * This is needed for USB drivers for example, as otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * they'll all appear as if the driver name was "usb".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @model: Device model name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @serial: Device serial number (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * @bus_info: Unique and stable device location identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @hw_revision: Hardware device revision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @topology_version: Monotonic counter for storing the version of the graph
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * topology. Should be incremented each time the topology changes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * @id: Unique ID used on the last registered graph object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * @entity_internal_idx: Unique internal entity ID used by the graph traversal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * algorithms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @entity_internal_idx_max: Allocated internal entity indices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * @entities: List of registered entities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @interfaces: List of registered interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @pads: List of registered pads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * @links: List of registered links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * @entity_notify: List of registered entity_notify callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * @graph_mutex: Protects access to struct media_device data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * @pm_count_walk: Graph walk for power state walk. Access serialised using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * graph_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @source_priv: Driver Private data for enable/disable source handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @enable_source: Enable Source Handler function pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * @disable_source: Disable Source Handler function pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * @ops: Operation handler callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * @req_queue_mutex: Serialise the MEDIA_REQUEST_IOC_QUEUE ioctl w.r.t.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * other operations that stop or start streaming.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * @request_id: Used to generate unique request IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * This structure represents an abstract high-level media device. It allows easy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * access to entities and provides basic media device-level support. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * structure can be allocated directly or embedded in a larger structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * The parent @dev is a physical device. It must be set before registering the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * media device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @model is a descriptive model name exported through sysfs. It doesn't have to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * be unique.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * @enable_source is a handler to find source entity for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * sink entity and activate the link between them if source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * entity is free. Drivers should call this handler before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * accessing the source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @disable_source is a handler to find source entity for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * sink entity and deactivate the link between them. Drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * should call this handler to release the source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Use-case: find tuner entity connected to the decoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * entity and check if it is available, and activate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * link between them from @enable_source and deactivate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * from @disable_source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * Bridge driver is expected to implement and set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * handler when &media_device is registered or when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * bridge driver finds the media_device during probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * Bridge driver sets source_priv with information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * necessary to run @enable_source and @disable_source handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * Callers should hold graph_mutex to access and call @enable_source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * and @disable_source handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct media_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* dev->driver_data points to this struct. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct media_devnode *devnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) char model[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) char driver_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) char serial[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) char bus_info[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) u32 hw_revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u64 topology_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct ida entity_internal_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int entity_internal_idx_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct list_head entities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct list_head interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct list_head pads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct list_head links;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* notify callback list invoked when a new entity is registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct list_head entity_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Serializes graph operations. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct mutex graph_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct media_graph pm_count_walk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) void *source_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int (*enable_source)(struct media_entity *entity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct media_pipeline *pipe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) void (*disable_source)(struct media_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) const struct media_device_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct mutex req_queue_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) atomic_t request_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* We don't need to include pci.h or usb.h here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct pci_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct usb_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #ifdef CONFIG_MEDIA_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* Supported link_notify @notification values. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #define MEDIA_DEV_NOTIFY_POST_LINK_CH 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * media_entity_enum_init - Initialise an entity enumeration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @ent_enum: Entity enumeration to be initialised
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * @mdev: The related media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * Return: zero on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static inline __must_check int media_entity_enum_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct media_entity_enum *ent_enum, struct media_device *mdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return __media_entity_enum_init(ent_enum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) mdev->entity_internal_idx_max + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * media_device_init() - Initializes a media device element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * This function initializes the media device prior to its registration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * The media device initialization and registration is split in two functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * to avoid race conditions and make the media device available to user-space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * before the media graph has been completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * So drivers need to first initialize the media device, register any entity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * within the media device, create pad to pad links and then finally register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * the media device by calling media_device_register() as a final step.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) void media_device_init(struct media_device *mdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * media_device_cleanup() - Cleanups a media device element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * This function that will destroy the graph_mutex that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * initialized in media_device_init().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void media_device_cleanup(struct media_device *mdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * __media_device_register() - Registers a media device element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * @owner: should be filled with %THIS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * Users, should, instead, call the media_device_register() macro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * The caller is responsible for initializing the &media_device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * before registration. The following fields of &media_device must be set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * - &media_entity.dev must point to the parent device (usually a &pci_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * &usb_interface or &platform_device instance).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * - &media_entity.model must be filled with the device model name as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * NUL-terminated UTF-8 string. The device/model revision must not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * stored in this field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * The following fields are optional:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * - &media_entity.serial is a unique serial number stored as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * NUL-terminated ASCII string. The field is big enough to store a GUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * in text form. If the hardware doesn't provide a unique serial number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * this field must be left empty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * - &media_entity.bus_info represents the location of the device in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * system as a NUL-terminated ASCII string. For PCI/PCIe devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * &media_entity.bus_info must be set to "PCI:" (or "PCIe:") followed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * the value of pci_name(). For USB devices,the usb_make_path() function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * must be used. This field is used by applications to distinguish between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * otherwise identical devices that don't provide a serial number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * - &media_entity.hw_revision is the hardware device revision in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * driver-specific format. When possible the revision should be formatted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * with the KERNEL_VERSION() macro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * #) Upon successful registration a character device named media[0-9]+ is created. The device major and minor numbers are dynamic. The model name is exported as a sysfs attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * #) Unregistering a media device that hasn't been registered is **NOT** safe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * Return: returns zero on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) int __must_check __media_device_register(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct module *owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * media_device_register() - Registers a media device element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * This macro calls __media_device_register() passing %THIS_MODULE as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * the __media_device_register() second argument (**owner**).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) #define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * media_device_unregister() - Unregisters a media device element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * It is safe to call this function on an unregistered (but initialised)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * media device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void media_device_unregister(struct media_device *mdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * media_device_register_entity() - registers a media entity inside a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * previously registered media device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * @entity: pointer to struct &media_entity to be registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * Entities are identified by a unique positive integer ID. The media
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * controller framework will such ID automatically. IDs are not guaranteed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * to be contiguous, and the ID number can change on newer Kernel versions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * So, neither the driver nor userspace should hardcode ID numbers to refer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * to the entities, but, instead, use the framework to find the ID, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * The media_entity name, type and flags fields should be initialized before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * calling media_device_register_entity(). Entities embedded in higher-level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * standard structures can have some of those fields set by the higher-level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * framework.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * If the device has pads, media_entity_pads_init() should be called before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * this function. Otherwise, the &media_entity.pad and &media_entity.num_pads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * should be zeroed before calling this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * Entities have flags that describe the entity capabilities and state:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * %MEDIA_ENT_FL_DEFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * indicates the default entity for a given type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * This can be used to report the default audio and video devices or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * default camera sensor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * Drivers should set the entity function before calling this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * Please notice that the values %MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * %MEDIA_ENT_F_UNKNOWN should not be used by the drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) int __must_check media_device_register_entity(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) struct media_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * media_device_unregister_entity() - unregisters a media entity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * @entity: pointer to struct &media_entity to be unregistered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * All links associated with the entity and all PADs are automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * unregistered from the media_device when this function is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) * Unregistering an entity will not change the IDs of the other entities and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * the previoully used ID will never be reused for a newly registered entities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * When a media device is unregistered, all its entities are unregistered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * automatically. No manual entities unregistration is then required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * The media_entity instance itself must be freed explicitly by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * the driver if required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) void media_device_unregister_entity(struct media_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * media_device_register_entity_notify() - Registers a media entity_notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) * callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * @mdev: The media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * @nptr: The media_entity_notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * When a new entity is registered, all the registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * media_entity_notify callbacks are invoked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) int __must_check media_device_register_entity_notify(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct media_entity_notify *nptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * media_device_unregister_entity_notify() - Unregister a media entity notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * @mdev: The media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * @nptr: The media_entity_notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) void media_device_unregister_entity_notify(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct media_entity_notify *nptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* Iterate over all entities. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #define media_device_for_each_entity(entity, mdev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) /* Iterate over all interfaces. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) #define media_device_for_each_intf(intf, mdev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /* Iterate over all pads. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) #define media_device_for_each_pad(pad, mdev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) list_for_each_entry(pad, &(mdev)->pads, graph_obj.list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /* Iterate over all links. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #define media_device_for_each_link(link, mdev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) list_for_each_entry(link, &(mdev)->links, graph_obj.list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * media_device_pci_init() - create and initialize a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * struct &media_device from a PCI device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * @pci_dev: pointer to struct pci_dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * @name: media device name. If %NULL, the routine will use the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * name for the pci device, given by pci_name() macro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) void media_device_pci_init(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) struct pci_dev *pci_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * __media_device_usb_init() - create and initialize a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * struct &media_device from a PCI device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * @udev: pointer to struct usb_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * @board_name: media device name. If %NULL, the routine will use the usb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * product name, if available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * @driver_name: name of the driver. if %NULL, the routine will use the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * given by ``udev->dev->driver->name``, with is usually the wrong
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * thing to do.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * It is better to call media_device_usb_init() instead, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * such macro fills driver_name with %KBUILD_MODNAME.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) void __media_device_usb_init(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) struct usb_device *udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) const char *board_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) const char *driver_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) static inline int media_device_register(struct media_device *mdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static inline void media_device_unregister(struct media_device *mdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) static inline int media_device_register_entity(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) struct media_entity *entity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) static inline void media_device_unregister_entity(struct media_entity *entity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) static inline int media_device_register_entity_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) struct media_entity_notify *nptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static inline void media_device_unregister_entity_notify(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct media_entity_notify *nptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) static inline void media_device_pci_init(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct pci_dev *pci_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static inline void __media_device_usb_init(struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct usb_device *udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) char *board_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) char *driver_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) #endif /* CONFIG_MEDIA_CONTROLLER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * media_device_usb_init() - create and initialize a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * struct &media_device from a PCI device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * @mdev: pointer to struct &media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * @udev: pointer to struct usb_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * @name: media device name. If %NULL, the routine will use the usb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * product name, if available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * This macro calls media_device_usb_init() passing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * media_device_usb_init() **driver_name** parameter filled with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * %KBUILD_MODNAME.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) #define media_device_usb_init(mdev, udev, name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) __media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) #endif