aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-03-21 07:03:26 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-15 15:11:07 -0400
commitbed8d8033037431be3968cd604f32ad8b7260600 (patch)
tree7d84aeb5052fb6b6f2467713f789292724654192 /drivers/media/video/soc_camera.c
parent8929c96378a162263c8e3e547975e283dfd17e7f (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/soc_camera.c')
-rw-r--r--drivers/media/video/soc_camera.c29
1 files changed, 15 insertions, 14 deletions
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}