hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/samples/v4l/v4l2-pci-skeleton.c
....@@ -58,6 +58,7 @@
5858 * @queue: vb2 video capture queue
5959 * @qlock: spinlock controlling access to buf_list and sequence
6060 * @buf_list: list of buffers queued for DMA
61
+ * @field: the field (TOP/BOTTOM/other) of the current buffer
6162 * @sequence: frame sequence counter
6263 */
6364 struct skeleton {
....@@ -80,13 +81,13 @@
8081 };
8182
8283 struct skel_buffer {
83
- struct vb2_buffer vb;
84
+ struct vb2_v4l2_buffer vb;
8485 struct list_head list;
8586 };
8687
87
-static inline struct skel_buffer *to_skel_buffer(struct vb2_buffer *vb2)
88
+static inline struct skel_buffer *to_skel_buffer(struct vb2_v4l2_buffer *vbuf)
8889 {
89
- return container_of(vb2, struct skel_buffer, vb);
90
+ return container_of(vbuf, struct skel_buffer, vb);
9091 }
9192
9293 static const struct pci_device_id skeleton_pci_tbl[] = {
....@@ -139,16 +140,16 @@
139140 spin_lock(&skel->qlock);
140141 list_del(&new_buf->list);
141142 spin_unlock(&skel->qlock);
142
- v4l2_get_timestamp(&new_buf->vb.v4l2_buf.timestamp);
143
- new_buf->vb.v4l2_buf.sequence = skel->sequence++;
144
- new_buf->vb.v4l2_buf.field = skel->field;
143
+ new_buf->vb.vb2_buf.timestamp = ktime_get_ns();
144
+ new_buf->vb.sequence = skel->sequence++;
145
+ new_buf->vb.field = skel->field;
145146 if (skel->format.field == V4L2_FIELD_ALTERNATE) {
146147 if (skel->field == V4L2_FIELD_BOTTOM)
147148 skel->field = V4L2_FIELD_TOP;
148149 else if (skel->field == V4L2_FIELD_TOP)
149150 skel->field = V4L2_FIELD_BOTTOM;
150151 }
151
- vb2_buffer_done(&new_buf->vb, VB2_BUF_STATE_DONE);
152
+ vb2_buffer_done(&new_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
152153 }
153154 #endif
154155 return IRQ_HANDLED;
....@@ -212,8 +213,9 @@
212213 */
213214 static void buffer_queue(struct vb2_buffer *vb)
214215 {
216
+ struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
215217 struct skeleton *skel = vb2_get_drv_priv(vb->vb2_queue);
216
- struct skel_buffer *buf = to_skel_buffer(vb);
218
+ struct skel_buffer *buf = to_skel_buffer(vbuf);
217219 unsigned long flags;
218220
219221 spin_lock_irqsave(&skel->qlock, flags);
....@@ -232,7 +234,7 @@
232234
233235 spin_lock_irqsave(&skel->qlock, flags);
234236 list_for_each_entry_safe(buf, node, &skel->buf_list, list) {
235
- vb2_buffer_done(&buf->vb, state);
237
+ vb2_buffer_done(&buf->vb.vb2_buf, state);
236238 list_del(&buf->list);
237239 }
238240 spin_unlock_irqrestore(&skel->qlock, flags);
....@@ -877,7 +879,7 @@
877879 vdev->tvnorms = SKEL_TVNORMS;
878880 video_set_drvdata(vdev, skel);
879881
880
- ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
882
+ ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
881883 if (ret)
882884 goto free_hdl;
883885