diff options
-rw-r--r-- | drivers/media/video/bttv-driver.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index f9d581cd31db..fdaff5bd6331 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c | |||
@@ -2029,19 +2029,33 @@ static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type) | |||
2029 | return 0; | 2029 | return 0; |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | static void | ||
2033 | pix_format_set_size (struct v4l2_pix_format * f, | ||
2034 | const struct bttv_format * fmt, | ||
2035 | unsigned int width, | ||
2036 | unsigned int height) | ||
2037 | { | ||
2038 | f->width = width; | ||
2039 | f->height = height; | ||
2040 | |||
2041 | if (fmt->flags & FORMAT_FLAGS_PLANAR) { | ||
2042 | f->bytesperline = width; /* Y plane */ | ||
2043 | f->sizeimage = (width * height * fmt->depth) >> 3; | ||
2044 | } else { | ||
2045 | f->bytesperline = (width * fmt->depth) >> 3; | ||
2046 | f->sizeimage = height * f->bytesperline; | ||
2047 | } | ||
2048 | } | ||
2049 | |||
2032 | static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f) | 2050 | static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f) |
2033 | { | 2051 | { |
2034 | switch (f->type) { | 2052 | switch (f->type) { |
2035 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 2053 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
2036 | memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format)); | 2054 | memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format)); |
2037 | f->fmt.pix.width = fh->width; | 2055 | pix_format_set_size (&f->fmt.pix, fh->fmt, |
2038 | f->fmt.pix.height = fh->height; | 2056 | fh->width, fh->height); |
2039 | f->fmt.pix.field = fh->cap.field; | 2057 | f->fmt.pix.field = fh->cap.field; |
2040 | f->fmt.pix.pixelformat = fh->fmt->fourcc; | 2058 | f->fmt.pix.pixelformat = fh->fmt->fourcc; |
2041 | f->fmt.pix.bytesperline = | ||
2042 | (f->fmt.pix.width * fh->fmt->depth) >> 3; | ||
2043 | f->fmt.pix.sizeimage = | ||
2044 | f->fmt.pix.height * f->fmt.pix.bytesperline; | ||
2045 | return 0; | 2059 | return 0; |
2046 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 2060 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
2047 | memset(&f->fmt.win,0,sizeof(struct v4l2_window)); | 2061 | memset(&f->fmt.win,0,sizeof(struct v4l2_window)); |
@@ -2106,11 +2120,9 @@ static int bttv_try_fmt(struct bttv_fh *fh, struct bttv *btv, | |||
2106 | f->fmt.pix.width = maxw; | 2120 | f->fmt.pix.width = maxw; |
2107 | if (f->fmt.pix.height > maxh) | 2121 | if (f->fmt.pix.height > maxh) |
2108 | f->fmt.pix.height = maxh; | 2122 | f->fmt.pix.height = maxh; |
2109 | f->fmt.pix.width &= ~0x03; | 2123 | pix_format_set_size (&f->fmt.pix, fmt, |
2110 | f->fmt.pix.bytesperline = | 2124 | f->fmt.pix.width & ~3, |
2111 | (f->fmt.pix.width * fmt->depth) >> 3; | 2125 | f->fmt.pix.height); |
2112 | f->fmt.pix.sizeimage = | ||
2113 | f->fmt.pix.height * f->fmt.pix.bytesperline; | ||
2114 | 2126 | ||
2115 | return 0; | 2127 | return 0; |
2116 | } | 2128 | } |