diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2009-05-30 20:45:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-23 02:21:18 -0400 |
commit | 4a6b8df2133c1f218a503e0432a9e6cc3d461a30 (patch) | |
tree | bcf8008f257eb6812cb8ea974c1f038acf8da0e2 /drivers/media/video/pxa_camera.c | |
parent | b0d3159be9a36fd8b7b1cf88b812d951add53d11 (diff) |
V4L/DVB (11902): pxa-camera: Use v4l bounding/alignment function
The v4l function has a better algorithm for aligning image size.
For instance the old code would change 159x243 into 156x240 to meet the
alignment requirements. The new function will use 160x243, which is a lot
closer to what was asked for originally.
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pxa_camera.c')
-rw-r--r-- | drivers/media/video/pxa_camera.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index f60de40fd21f..46e0d8ad880f 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -163,13 +163,6 @@ | |||
163 | CICR0_EOFM | CICR0_FOM) | 163 | CICR0_EOFM | CICR0_FOM) |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * YUV422P picture size should be a multiple of 16, so the heuristic aligns | ||
167 | * height, width on 4 byte boundaries to reach the 16 multiple for the size. | ||
168 | */ | ||
169 | #define YUV422P_X_Y_ALIGN 4 | ||
170 | #define YUV422P_SIZE_ALIGN YUV422P_X_Y_ALIGN * YUV422P_X_Y_ALIGN | ||
171 | |||
172 | /* | ||
173 | * Structures | 166 | * Structures |
174 | */ | 167 | */ |
175 | enum pxa_camera_active_dma { | 168 | enum pxa_camera_active_dma { |
@@ -1398,28 +1391,15 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd, | |||
1398 | return -EINVAL; | 1391 | return -EINVAL; |
1399 | } | 1392 | } |
1400 | 1393 | ||
1401 | /* limit to pxa hardware capabilities */ | ||
1402 | if (pix->height < 32) | ||
1403 | pix->height = 32; | ||
1404 | if (pix->height > 2048) | ||
1405 | pix->height = 2048; | ||
1406 | if (pix->width < 48) | ||
1407 | pix->width = 48; | ||
1408 | if (pix->width > 2048) | ||
1409 | pix->width = 2048; | ||
1410 | pix->width &= ~0x01; | ||
1411 | |||
1412 | /* | 1394 | /* |
1413 | * YUV422P planar format requires images size to be a 16 bytes | 1395 | * Limit to pxa hardware capabilities. YUV422P planar format requires |
1414 | * multiple. If not, zeros will be inserted between Y and U planes, and | 1396 | * images size to be a multiple of 16 bytes. If not, zeros will be |
1415 | * U and V planes, and YUV422P standard would be violated. | 1397 | * inserted between Y and U planes, and U and V planes, which violates |
1398 | * the YUV422P standard. | ||
1416 | */ | 1399 | */ |
1417 | if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P) { | 1400 | v4l_bound_align_image(&pix->width, 48, 2048, 1, |
1418 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | 1401 | &pix->height, 32, 2048, 0, |
1419 | pix->height = ALIGN(pix->height, YUV422P_X_Y_ALIGN); | 1402 | xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0); |
1420 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | ||
1421 | pix->width = ALIGN(pix->width, YUV422P_X_Y_ALIGN); | ||
1422 | } | ||
1423 | 1403 | ||
1424 | pix->bytesperline = pix->width * | 1404 | pix->bytesperline = pix->width * |
1425 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); | 1405 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); |