diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2016-12-12 06:16:49 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-01-31 07:53:56 -0500 |
commit | bb1d34875cac75b809230aafbceebce813c9175b (patch) | |
tree | e2e317f37d94c7e6376a1f0f776dc35921f115b0 | |
parent | 239dd6164c867f31e1d37b065724c893237d2627 (diff) |
[media] uvcvideo: (cosmetic) Add and use an inline function
Add an inline function to obtain a struct uvc_buffer pointer from a
struct vb2_v4l2_buffer one.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/usb/uvc/uvc_queue.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 77edd206d345..0cc7ae23604d 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c | |||
@@ -43,6 +43,11 @@ uvc_queue_to_stream(struct uvc_video_queue *queue) | |||
43 | return container_of(queue, struct uvc_streaming, queue); | 43 | return container_of(queue, struct uvc_streaming, queue); |
44 | } | 44 | } |
45 | 45 | ||
46 | static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf) | ||
47 | { | ||
48 | return container_of(buf, struct uvc_buffer, buf); | ||
49 | } | ||
50 | |||
46 | /* | 51 | /* |
47 | * Return all queued buffers to videobuf2 in the requested state. | 52 | * Return all queued buffers to videobuf2 in the requested state. |
48 | * | 53 | * |
@@ -89,7 +94,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) | |||
89 | { | 94 | { |
90 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | 95 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
91 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 96 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
92 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); | 97 | struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); |
93 | 98 | ||
94 | if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 99 | if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && |
95 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { | 100 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { |
@@ -116,7 +121,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) | |||
116 | { | 121 | { |
117 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | 122 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
118 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 123 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
119 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); | 124 | struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); |
120 | unsigned long flags; | 125 | unsigned long flags; |
121 | 126 | ||
122 | spin_lock_irqsave(&queue->irqlock, flags); | 127 | spin_lock_irqsave(&queue->irqlock, flags); |
@@ -138,7 +143,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) | |||
138 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | 143 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
139 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 144 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
140 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); | 145 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); |
141 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); | 146 | struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf); |
142 | 147 | ||
143 | if (vb->state == VB2_BUF_STATE_DONE) | 148 | if (vb->state == VB2_BUF_STATE_DONE) |
144 | uvc_video_clock_update(stream, vbuf, buf); | 149 | uvc_video_clock_update(stream, vbuf, buf); |