hackrf.c (16217dc79dbc599b110dda26d0421df47904bba4) hackrf.c (1bc177174b97e4df8d27b6c3cdd79ffea9e2d18e)
1/*
2 * HackRF driver
3 *
4 * Copyright (C) 2014 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 115 unchanged lines hidden (view full) ---

124 struct v4l2_device v4l2_dev;
125
126 /* videobuf2 queue and queued buffers list */
127 struct vb2_queue rx_vb2_queue;
128 struct vb2_queue tx_vb2_queue;
129 struct list_head rx_buffer_list;
130 struct list_head tx_buffer_list;
131 spinlock_t buffer_list_lock; /* Protects buffer_list */
1/*
2 * HackRF driver
3 *
4 * Copyright (C) 2014 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 115 unchanged lines hidden (view full) ---

124 struct v4l2_device v4l2_dev;
125
126 /* videobuf2 queue and queued buffers list */
127 struct vb2_queue rx_vb2_queue;
128 struct vb2_queue tx_vb2_queue;
129 struct list_head rx_buffer_list;
130 struct list_head tx_buffer_list;
131 spinlock_t buffer_list_lock; /* Protects buffer_list */
132 unsigned sequence; /* Buffer sequence counter */
132 unsigned int sequence; /* Buffer sequence counter */
133 unsigned int vb_full; /* vb is full and packets dropped */
134 unsigned int vb_empty; /* vb is empty and packets dropped */
135
136 /* Note if taking both locks v4l2_lock must always be locked first! */
137 struct mutex v4l2_lock; /* Protects everything else */
138 struct mutex vb_queue_lock; /* Protects vb_queue */
139
140 struct urb *urb_list[MAX_BULK_BUFS];

--- 545 unchanged lines hidden (view full) ---

686 complete = &hackrf_urb_complete_out;
687 }
688
689 /* allocate the URBs */
690 for (i = 0; i < MAX_BULK_BUFS; i++) {
691 dev_dbg(dev->dev, "alloc urb=%d\n", i);
692 dev->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
693 if (!dev->urb_list[i]) {
133 unsigned int vb_full; /* vb is full and packets dropped */
134 unsigned int vb_empty; /* vb is empty and packets dropped */
135
136 /* Note if taking both locks v4l2_lock must always be locked first! */
137 struct mutex v4l2_lock; /* Protects everything else */
138 struct mutex vb_queue_lock; /* Protects vb_queue */
139
140 struct urb *urb_list[MAX_BULK_BUFS];

--- 545 unchanged lines hidden (view full) ---

686 complete = &hackrf_urb_complete_out;
687 }
688
689 /* allocate the URBs */
690 for (i = 0; i < MAX_BULK_BUFS; i++) {
691 dev_dbg(dev->dev, "alloc urb=%d\n", i);
692 dev->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
693 if (!dev->urb_list[i]) {
694 dev_dbg(dev->dev, "failed\n");
695 for (j = 0; j < i; j++)
696 usb_free_urb(dev->urb_list[j]);
697 return -ENOMEM;
698 }
699 usb_fill_bulk_urb(dev->urb_list[i],
700 dev->udev,
701 pipe,
702 dev->buf_list[i],

--- 184 unchanged lines hidden (view full) ---

887 if (vq->type == V4L2_BUF_TYPE_SDR_CAPTURE)
888 clear_bit(RX_ON, &dev->flags);
889 else
890 clear_bit(TX_ON, &dev->flags);
891
892 mutex_unlock(&dev->v4l2_lock);
893}
894
694 for (j = 0; j < i; j++)
695 usb_free_urb(dev->urb_list[j]);
696 return -ENOMEM;
697 }
698 usb_fill_bulk_urb(dev->urb_list[i],
699 dev->udev,
700 pipe,
701 dev->buf_list[i],

--- 184 unchanged lines hidden (view full) ---

886 if (vq->type == V4L2_BUF_TYPE_SDR_CAPTURE)
887 clear_bit(RX_ON, &dev->flags);
888 else
889 clear_bit(TX_ON, &dev->flags);
890
891 mutex_unlock(&dev->v4l2_lock);
892}
893
895static struct vb2_ops hackrf_vb2_ops = {
894static const struct vb2_ops hackrf_vb2_ops = {
896 .queue_setup = hackrf_queue_setup,
897 .buf_queue = hackrf_buf_queue,
898 .start_streaming = hackrf_start_streaming,
899 .stop_streaming = hackrf_stop_streaming,
900 .wait_prepare = vb2_ops_wait_prepare,
901 .wait_finish = vb2_ops_wait_finish,
902};
903

--- 664 unchanged lines hidden ---
895 .queue_setup = hackrf_queue_setup,
896 .buf_queue = hackrf_buf_queue,
897 .start_streaming = hackrf_start_streaming,
898 .stop_streaming = hackrf_stop_streaming,
899 .wait_prepare = vb2_ops_wait_prepare,
900 .wait_finish = vb2_ops_wait_finish,
901};
902

--- 664 unchanged lines hidden ---