diff options
author | Junghak Sung <jh1009.sung@samsung.com> | 2015-09-22 09:30:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-10-01 08:04:43 -0400 |
commit | 2d7007153f0c9b1dd00c01894df7d26ddc32b79f (patch) | |
tree | 8320f9d22f45dd7dcea64088b50ff706bb0082b2 /drivers/media/usb/pwc/pwc-if.c | |
parent | c139990e842d550db2f59bd4f5993bba90f140e0 (diff) |
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb/pwc/pwc-if.c')
-rw-r--r-- | drivers/media/usb/pwc/pwc-if.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index 702267e208ba..3f5395a7fafe 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c | |||
@@ -240,9 +240,9 @@ static void pwc_frame_complete(struct pwc_device *pdev) | |||
240 | PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes);" | 240 | PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes);" |
241 | " discarded.\n", fbuf->filled); | 241 | " discarded.\n", fbuf->filled); |
242 | } else { | 242 | } else { |
243 | fbuf->vb.v4l2_buf.field = V4L2_FIELD_NONE; | 243 | fbuf->vb.field = V4L2_FIELD_NONE; |
244 | fbuf->vb.v4l2_buf.sequence = pdev->vframe_count; | 244 | fbuf->vb.sequence = pdev->vframe_count; |
245 | vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE); | 245 | vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); |
246 | pdev->fill_buf = NULL; | 246 | pdev->fill_buf = NULL; |
247 | pdev->vsync = 0; | 247 | pdev->vsync = 0; |
248 | } | 248 | } |
@@ -287,7 +287,7 @@ static void pwc_isoc_handler(struct urb *urb) | |||
287 | { | 287 | { |
288 | PWC_ERROR("Too many ISOC errors, bailing out.\n"); | 288 | PWC_ERROR("Too many ISOC errors, bailing out.\n"); |
289 | if (pdev->fill_buf) { | 289 | if (pdev->fill_buf) { |
290 | vb2_buffer_done(&pdev->fill_buf->vb, | 290 | vb2_buffer_done(&pdev->fill_buf->vb.vb2_buf, |
291 | VB2_BUF_STATE_ERROR); | 291 | VB2_BUF_STATE_ERROR); |
292 | pdev->fill_buf = NULL; | 292 | pdev->fill_buf = NULL; |
293 | } | 293 | } |
@@ -317,7 +317,7 @@ static void pwc_isoc_handler(struct urb *urb) | |||
317 | 317 | ||
318 | if (pdev->vsync == 1) { | 318 | if (pdev->vsync == 1) { |
319 | v4l2_get_timestamp( | 319 | v4l2_get_timestamp( |
320 | &fbuf->vb.v4l2_buf.timestamp); | 320 | &fbuf->vb.timestamp); |
321 | pdev->vsync = 2; | 321 | pdev->vsync = 2; |
322 | } | 322 | } |
323 | 323 | ||
@@ -520,7 +520,7 @@ static void pwc_cleanup_queued_bufs(struct pwc_device *pdev, | |||
520 | buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf, | 520 | buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf, |
521 | list); | 521 | list); |
522 | list_del(&buf->list); | 522 | list_del(&buf->list); |
523 | vb2_buffer_done(&buf->vb, state); | 523 | vb2_buffer_done(&buf->vb.vb2_buf, state); |
524 | } | 524 | } |
525 | spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags); | 525 | spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags); |
526 | } | 526 | } |
@@ -594,7 +594,9 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
594 | 594 | ||
595 | static int buffer_init(struct vb2_buffer *vb) | 595 | static int buffer_init(struct vb2_buffer *vb) |
596 | { | 596 | { |
597 | struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); | 597 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
598 | struct pwc_frame_buf *buf = | ||
599 | container_of(vbuf, struct pwc_frame_buf, vb); | ||
598 | 600 | ||
599 | /* need vmalloc since frame buffer > 128K */ | 601 | /* need vmalloc since frame buffer > 128K */ |
600 | buf->data = vzalloc(PWC_FRAME_SIZE); | 602 | buf->data = vzalloc(PWC_FRAME_SIZE); |
@@ -618,7 +620,9 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
618 | static void buffer_finish(struct vb2_buffer *vb) | 620 | static void buffer_finish(struct vb2_buffer *vb) |
619 | { | 621 | { |
620 | struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); | 622 | struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); |
621 | struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); | 623 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
624 | struct pwc_frame_buf *buf = | ||
625 | container_of(vbuf, struct pwc_frame_buf, vb); | ||
622 | 626 | ||
623 | if (vb->state == VB2_BUF_STATE_DONE) { | 627 | if (vb->state == VB2_BUF_STATE_DONE) { |
624 | /* | 628 | /* |
@@ -633,7 +637,9 @@ static void buffer_finish(struct vb2_buffer *vb) | |||
633 | 637 | ||
634 | static void buffer_cleanup(struct vb2_buffer *vb) | 638 | static void buffer_cleanup(struct vb2_buffer *vb) |
635 | { | 639 | { |
636 | struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); | 640 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
641 | struct pwc_frame_buf *buf = | ||
642 | container_of(vbuf, struct pwc_frame_buf, vb); | ||
637 | 643 | ||
638 | vfree(buf->data); | 644 | vfree(buf->data); |
639 | } | 645 | } |
@@ -641,12 +647,14 @@ static void buffer_cleanup(struct vb2_buffer *vb) | |||
641 | static void buffer_queue(struct vb2_buffer *vb) | 647 | static void buffer_queue(struct vb2_buffer *vb) |
642 | { | 648 | { |
643 | struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); | 649 | struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); |
644 | struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); | 650 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
651 | struct pwc_frame_buf *buf = | ||
652 | container_of(vbuf, struct pwc_frame_buf, vb); | ||
645 | unsigned long flags = 0; | 653 | unsigned long flags = 0; |
646 | 654 | ||
647 | /* Check the device has not disconnected between prep and queuing */ | 655 | /* Check the device has not disconnected between prep and queuing */ |
648 | if (!pdev->udev) { | 656 | if (!pdev->udev) { |
649 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | 657 | vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); |
650 | return; | 658 | return; |
651 | } | 659 | } |
652 | 660 | ||
@@ -695,7 +703,8 @@ static void stop_streaming(struct vb2_queue *vq) | |||
695 | 703 | ||
696 | pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_ERROR); | 704 | pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_ERROR); |
697 | if (pdev->fill_buf) | 705 | if (pdev->fill_buf) |
698 | vb2_buffer_done(&pdev->fill_buf->vb, VB2_BUF_STATE_ERROR); | 706 | vb2_buffer_done(&pdev->fill_buf->vb.vb2_buf, |
707 | VB2_BUF_STATE_ERROR); | ||
699 | mutex_unlock(&pdev->v4l2_lock); | 708 | mutex_unlock(&pdev->v4l2_lock); |
700 | } | 709 | } |
701 | 710 | ||