diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-03-21 07:03:26 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-15 15:11:07 -0400 |
commit | bed8d8033037431be3968cd604f32ad8b7260600 (patch) | |
tree | 7d84aeb5052fb6b6f2467713f789292724654192 /drivers/media/video | |
parent | 8929c96378a162263c8e3e547975e283dfd17e7f (diff) |
[media] soc-camera: Honor user-requested bytesperline and sizeimage
Compute the bytesperline and sizeimage values when trying/setting
formats or when allocating buffers by taking the user-requested values
into account.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/mx3_camera.c | 20 | ||||
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 20 | ||||
-rw-r--r-- | drivers/media/video/soc_camera.c | 29 |
3 files changed, 43 insertions, 26 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index 2bdda6ca13c0..02d54a057b60 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c | |||
@@ -206,17 +206,25 @@ static int mx3_videobuf_setup(struct vb2_queue *vq, | |||
206 | if (fmt) { | 206 | if (fmt) { |
207 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, | 207 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, |
208 | fmt->fmt.pix.pixelformat); | 208 | fmt->fmt.pix.pixelformat); |
209 | int bytes_per_line; | 209 | unsigned int bytes_per_line; |
210 | int ret; | ||
210 | 211 | ||
211 | if (!xlate) | 212 | if (!xlate) |
212 | return -EINVAL; | 213 | return -EINVAL; |
213 | 214 | ||
214 | bytes_per_line = soc_mbus_bytes_per_line(fmt->fmt.pix.width, | 215 | ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, |
215 | xlate->host_fmt); | 216 | xlate->host_fmt); |
216 | if (bytes_per_line < 0) | 217 | if (ret < 0) |
217 | return bytes_per_line; | 218 | return ret; |
219 | |||
220 | bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); | ||
221 | |||
222 | ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, | ||
223 | fmt->fmt.pix.height); | ||
224 | if (ret < 0) | ||
225 | return ret; | ||
218 | 226 | ||
219 | sizes[0] = bytes_per_line * fmt->fmt.pix.height; | 227 | sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); |
220 | } else { | 228 | } else { |
221 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | 229 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ |
222 | sizes[0] = icd->sizeimage; | 230 | sizes[0] = icd->sizeimage; |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 87b07bcab323..79bec15cc4a3 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -214,17 +214,25 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, | |||
214 | if (fmt) { | 214 | if (fmt) { |
215 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, | 215 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, |
216 | fmt->fmt.pix.pixelformat); | 216 | fmt->fmt.pix.pixelformat); |
217 | int bytes_per_line; | 217 | unsigned int bytes_per_line; |
218 | int ret; | ||
218 | 219 | ||
219 | if (!xlate) | 220 | if (!xlate) |
220 | return -EINVAL; | 221 | return -EINVAL; |
221 | 222 | ||
222 | bytes_per_line = soc_mbus_bytes_per_line(fmt->fmt.pix.width, | 223 | ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, |
223 | xlate->host_fmt); | 224 | xlate->host_fmt); |
224 | if (bytes_per_line < 0) | 225 | if (ret < 0) |
225 | return bytes_per_line; | 226 | return ret; |
227 | |||
228 | bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); | ||
229 | |||
230 | ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, | ||
231 | fmt->fmt.pix.height); | ||
232 | if (ret < 0) | ||
233 | return ret; | ||
226 | 234 | ||
227 | sizes[0] = bytes_per_line * fmt->fmt.pix.height; | 235 | sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); |
228 | } else { | 236 | } else { |
229 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | 237 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ |
230 | sizes[0] = icd->sizeimage; | 238 | sizes[0] = icd->sizeimage; |
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index d86b15084628..5e3274e55756 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -164,6 +164,7 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd, | |||
164 | struct v4l2_format *f) | 164 | struct v4l2_format *f) |
165 | { | 165 | { |
166 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 166 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
167 | const struct soc_camera_format_xlate *xlate; | ||
167 | struct v4l2_pix_format *pix = &f->fmt.pix; | 168 | struct v4l2_pix_format *pix = &f->fmt.pix; |
168 | int ret; | 169 | int ret; |
169 | 170 | ||
@@ -177,22 +178,22 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd, | |||
177 | if (ret < 0) | 178 | if (ret < 0) |
178 | return ret; | 179 | return ret; |
179 | 180 | ||
180 | if (!pix->sizeimage) { | 181 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); |
181 | if (!pix->bytesperline) { | 182 | if (!xlate) |
182 | const struct soc_camera_format_xlate *xlate; | 183 | return -EINVAL; |
183 | 184 | ||
184 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); | 185 | ret = soc_mbus_bytes_per_line(pix->width, xlate->host_fmt); |
185 | if (!xlate) | 186 | if (ret < 0) |
186 | return -EINVAL; | 187 | return ret; |
187 | 188 | ||
188 | ret = soc_mbus_bytes_per_line(pix->width, | 189 | pix->bytesperline = max_t(u32, pix->bytesperline, ret); |
189 | xlate->host_fmt); | 190 | |
190 | if (ret > 0) | 191 | ret = soc_mbus_image_size(xlate->host_fmt, pix->bytesperline, |
191 | pix->bytesperline = ret; | 192 | pix->height); |
192 | } | 193 | if (ret < 0) |
193 | if (pix->bytesperline) | 194 | return ret; |
194 | pix->sizeimage = pix->bytesperline * pix->height; | 195 | |
195 | } | 196 | pix->sizeimage = max_t(u32, pix->sizeimage, ret); |
196 | 197 | ||
197 | return 0; | 198 | return 0; |
198 | } | 199 | } |