diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-02-07 05:56:11 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-05 12:24:28 -0500 |
commit | c13eb7039f612cc666764d6685a3764f4e6c8821 (patch) | |
tree | bb8e5321cff2604514ff31121547149538bc505f /drivers/media/pci | |
parent | 3d4b8035050dbca905ab55ecc0a0de16f9ef11bf (diff) |
[media] bttv: fix try_fmt_vid_overlay and setup initial overlay size
try_fmt_vid_overlay should map incorrect sizes and fields to valid values.
It also expects that an initial overlay size is defined so g_fmt_vid_overlay
returns valid information.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r-- | drivers/media/pci/bt8xx/bttv-driver.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index 0fdaef225c9e..b5100da854c0 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c | |||
@@ -2111,22 +2111,33 @@ limit_scaled_size_lock (struct bttv_fh * fh, | |||
2111 | may also adjust the current cropping parameters to get closer | 2111 | may also adjust the current cropping parameters to get closer |
2112 | to the desired window size. */ | 2112 | to the desired window size. */ |
2113 | static int | 2113 | static int |
2114 | verify_window_lock (struct bttv_fh * fh, | 2114 | verify_window_lock(struct bttv_fh *fh, struct v4l2_window *win, |
2115 | struct v4l2_window * win, | 2115 | int adjust_size, int adjust_crop) |
2116 | int adjust_size, | ||
2117 | int adjust_crop) | ||
2118 | { | 2116 | { |
2119 | enum v4l2_field field; | 2117 | enum v4l2_field field; |
2120 | unsigned int width_mask; | 2118 | unsigned int width_mask; |
2121 | int rc; | 2119 | int rc; |
2122 | 2120 | ||
2123 | if (win->w.width < 48 || win->w.height < 32) | 2121 | if (win->w.width < 48) |
2124 | return -EINVAL; | 2122 | win->w.width = 48; |
2123 | if (win->w.height < 32) | ||
2124 | win->w.height = 32; | ||
2125 | if (win->clipcount > 2048) | 2125 | if (win->clipcount > 2048) |
2126 | return -EINVAL; | 2126 | win->clipcount = 2048; |
2127 | 2127 | ||
2128 | win->chromakey = 0; | ||
2129 | win->global_alpha = 0; | ||
2128 | field = win->field; | 2130 | field = win->field; |
2129 | 2131 | ||
2132 | switch (field) { | ||
2133 | case V4L2_FIELD_TOP: | ||
2134 | case V4L2_FIELD_BOTTOM: | ||
2135 | case V4L2_FIELD_INTERLACED: | ||
2136 | break; | ||
2137 | default: | ||
2138 | field = V4L2_FIELD_ANY; | ||
2139 | break; | ||
2140 | } | ||
2130 | if (V4L2_FIELD_ANY == field) { | 2141 | if (V4L2_FIELD_ANY == field) { |
2131 | __s32 height2; | 2142 | __s32 height2; |
2132 | 2143 | ||
@@ -2135,18 +2146,11 @@ verify_window_lock (struct bttv_fh * fh, | |||
2135 | ? V4L2_FIELD_INTERLACED | 2146 | ? V4L2_FIELD_INTERLACED |
2136 | : V4L2_FIELD_TOP; | 2147 | : V4L2_FIELD_TOP; |
2137 | } | 2148 | } |
2138 | switch (field) { | 2149 | win->field = field; |
2139 | case V4L2_FIELD_TOP: | ||
2140 | case V4L2_FIELD_BOTTOM: | ||
2141 | case V4L2_FIELD_INTERLACED: | ||
2142 | break; | ||
2143 | default: | ||
2144 | return -EINVAL; | ||
2145 | } | ||
2146 | 2150 | ||
2147 | /* 4-byte alignment. */ | ||
2148 | if (NULL == fh->ovfmt) | 2151 | if (NULL == fh->ovfmt) |
2149 | return -EINVAL; | 2152 | return -EINVAL; |
2153 | /* 4-byte alignment. */ | ||
2150 | width_mask = ~0; | 2154 | width_mask = ~0; |
2151 | switch (fh->ovfmt->depth) { | 2155 | switch (fh->ovfmt->depth) { |
2152 | case 8: | 2156 | case 8: |
@@ -2171,8 +2175,6 @@ verify_window_lock (struct bttv_fh * fh, | |||
2171 | adjust_size, adjust_crop); | 2175 | adjust_size, adjust_crop); |
2172 | if (0 != rc) | 2176 | if (0 != rc) |
2173 | return rc; | 2177 | return rc; |
2174 | |||
2175 | win->field = field; | ||
2176 | return 0; | 2178 | return 0; |
2177 | } | 2179 | } |
2178 | 2180 | ||
@@ -2407,9 +2409,10 @@ static int bttv_try_fmt_vid_overlay(struct file *file, void *priv, | |||
2407 | { | 2409 | { |
2408 | struct bttv_fh *fh = priv; | 2410 | struct bttv_fh *fh = priv; |
2409 | 2411 | ||
2410 | return verify_window_lock(fh, &f->fmt.win, | 2412 | verify_window_lock(fh, &f->fmt.win, |
2411 | /* adjust_size */ 1, | 2413 | /* adjust_size */ 1, |
2412 | /* adjust_crop */ 0); | 2414 | /* adjust_crop */ 0); |
2415 | return 0; | ||
2413 | } | 2416 | } |
2414 | 2417 | ||
2415 | static int bttv_s_fmt_vid_cap(struct file *file, void *priv, | 2418 | static int bttv_s_fmt_vid_cap(struct file *file, void *priv, |
@@ -4146,6 +4149,9 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) | |||
4146 | btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | 4149 | btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
4147 | btv->init.width = 320; | 4150 | btv->init.width = 320; |
4148 | btv->init.height = 240; | 4151 | btv->init.height = 240; |
4152 | btv->init.ov.w.width = 320; | ||
4153 | btv->init.ov.w.height = 240; | ||
4154 | btv->init.ov.field = V4L2_FIELD_INTERLACED; | ||
4149 | btv->input = 0; | 4155 | btv->input = 0; |
4150 | 4156 | ||
4151 | v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops, | 4157 | v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops, |