hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/include/media/media-device.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Media device
34 *
....@@ -5,15 +6,6 @@
56 *
67 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
78 * Sakari Ailus <sakari.ailus@iki.fi>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
179 */
1810
1911 #ifndef _MEDIA_DEVICE_H
....@@ -27,6 +19,7 @@
2719
2820 struct ida;
2921 struct device;
22
+struct media_device;
3023
3124 /**
3225 * struct media_entity_notify - Media Entity Notify
....@@ -50,10 +43,32 @@
5043 * struct media_device_ops - Media device operations
5144 * @link_notify: Link state change notification callback. This callback is
5245 * called with the graph_mutex held.
46
+ * @req_alloc: Allocate a request. Set this if you need to allocate a struct
47
+ * larger then struct media_request. @req_alloc and @req_free must
48
+ * either both be set or both be NULL.
49
+ * @req_free: Free a request. Set this if @req_alloc was set as well, leave
50
+ * to NULL otherwise.
51
+ * @req_validate: Validate a request, but do not queue yet. The req_queue_mutex
52
+ * lock is held when this op is called.
53
+ * @req_queue: Queue a validated request, cannot fail. If something goes
54
+ * wrong when queueing this request then it should be marked
55
+ * as such internally in the driver and any related buffers
56
+ * must eventually return to vb2 with state VB2_BUF_STATE_ERROR.
57
+ * The req_queue_mutex lock is held when this op is called.
58
+ * It is important that vb2 buffer objects are queued last after
59
+ * all other object types are queued: queueing a buffer kickstarts
60
+ * the request processing, so all other objects related to the
61
+ * request (and thus the buffer) must be available to the driver.
62
+ * And once a buffer is queued, then the driver can complete
63
+ * or delete objects from the request before req_queue exits.
5364 */
5465 struct media_device_ops {
5566 int (*link_notify)(struct media_link *link, u32 flags,
5667 unsigned int notification);
68
+ struct media_request *(*req_alloc)(struct media_device *mdev);
69
+ void (*req_free)(struct media_request *req);
70
+ int (*req_validate)(struct media_request *req);
71
+ void (*req_queue)(struct media_request *req);
5772 };
5873
5974 /**
....@@ -88,6 +103,9 @@
88103 * @disable_source: Disable Source Handler function pointer
89104 *
90105 * @ops: Operation handler callbacks
106
+ * @req_queue_mutex: Serialise the MEDIA_REQUEST_IOC_QUEUE ioctl w.r.t.
107
+ * other operations that stop or start streaming.
108
+ * @request_id: Used to generate unique request IDs
91109 *
92110 * This structure represents an abstract high-level media device. It allows easy
93111 * access to entities and provides basic media device-level support. The
....@@ -110,7 +128,7 @@
110128 *
111129 * Use-case: find tuner entity connected to the decoder
112130 * entity and check if it is available, and activate the
113
- * the link between them from @enable_source and deactivate
131
+ * link between them from @enable_source and deactivate
114132 * from @disable_source.
115133 *
116134 * .. note::
....@@ -158,6 +176,9 @@
158176 void (*disable_source)(struct media_entity *entity);
159177
160178 const struct media_device_ops *ops;
179
+
180
+ struct mutex req_queue_mutex;
181
+ atomic_t request_id;
161182 };
162183
163184 /* We don't need to include pci.h or usb.h here */