.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Media device |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
---|
7 | 8 | * 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. |
---|
17 | 9 | */ |
---|
18 | 10 | |
---|
19 | 11 | #ifndef _MEDIA_DEVICE_H |
---|
.. | .. |
---|
27 | 19 | |
---|
28 | 20 | struct ida; |
---|
29 | 21 | struct device; |
---|
| 22 | +struct media_device; |
---|
30 | 23 | |
---|
31 | 24 | /** |
---|
32 | 25 | * struct media_entity_notify - Media Entity Notify |
---|
.. | .. |
---|
50 | 43 | * struct media_device_ops - Media device operations |
---|
51 | 44 | * @link_notify: Link state change notification callback. This callback is |
---|
52 | 45 | * 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. |
---|
53 | 64 | */ |
---|
54 | 65 | struct media_device_ops { |
---|
55 | 66 | int (*link_notify)(struct media_link *link, u32 flags, |
---|
56 | 67 | 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); |
---|
57 | 72 | }; |
---|
58 | 73 | |
---|
59 | 74 | /** |
---|
.. | .. |
---|
88 | 103 | * @disable_source: Disable Source Handler function pointer |
---|
89 | 104 | * |
---|
90 | 105 | * @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 |
---|
91 | 109 | * |
---|
92 | 110 | * This structure represents an abstract high-level media device. It allows easy |
---|
93 | 111 | * access to entities and provides basic media device-level support. The |
---|
.. | .. |
---|
110 | 128 | * |
---|
111 | 129 | * Use-case: find tuner entity connected to the decoder |
---|
112 | 130 | * 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 |
---|
114 | 132 | * from @disable_source. |
---|
115 | 133 | * |
---|
116 | 134 | * .. note:: |
---|
.. | .. |
---|
158 | 176 | void (*disable_source)(struct media_entity *entity); |
---|
159 | 177 | |
---|
160 | 178 | const struct media_device_ops *ops; |
---|
| 179 | + |
---|
| 180 | + struct mutex req_queue_mutex; |
---|
| 181 | + atomic_t request_id; |
---|
161 | 182 | }; |
---|
162 | 183 | |
---|
163 | 184 | /* We don't need to include pci.h or usb.h here */ |
---|