aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pxa_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <lyakh@axis700.grange>2008-12-01 07:44:59 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:22 -0500
commit25c4d74ea6f07f2aaa3df537619680ba967043f5 (patch)
tree58a33458a15e9720adc027ef443828550ba1f0eb /drivers/media/video/pxa_camera.c
parentabe4c4710386a4859dae9193bfc9a1f0e3c60db4 (diff)
V4L/DVB (9787): soc-camera: let camera host drivers decide upon pixel format
Pixel format requested by the user is not necessarily the same, as what a sensor driver provides. There are situations, when a camera host driver provides the required format, but requires a different format from the sensor. Further, the list of formats, supported by sensors is pretty static and can be pretty good described with a constant list of structures. Whereas decisions, made by camera host drivers to support requested formats can be quite complex, therefore it is better to let the host driver do the work. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> 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.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index 2a811f8584b5..a375872b1342 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -907,17 +907,43 @@ static int pxa_camera_try_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
907static int pxa_camera_set_fmt_cap(struct soc_camera_device *icd, 907static int pxa_camera_set_fmt_cap(struct soc_camera_device *icd,
908 __u32 pixfmt, struct v4l2_rect *rect) 908 __u32 pixfmt, struct v4l2_rect *rect)
909{ 909{
910 return icd->ops->set_fmt_cap(icd, pixfmt, rect); 910 const struct soc_camera_data_format *cam_fmt;
911 int ret;
912
913 /*
914 * TODO: find a suitable supported by the SoC output format, check
915 * whether the sensor supports one of acceptable input formats.
916 */
917 if (pixfmt) {
918 cam_fmt = soc_camera_format_by_fourcc(icd, pixfmt);
919 if (!cam_fmt)
920 return -EINVAL;
921 }
922
923 ret = icd->ops->set_fmt_cap(icd, pixfmt, rect);
924 if (pixfmt && !ret)
925 icd->current_fmt = cam_fmt;
926
927 return ret;
911} 928}
912 929
913static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd, 930static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd,
914 struct v4l2_format *f) 931 struct v4l2_format *f)
915{ 932{
933 const struct soc_camera_data_format *cam_fmt;
916 int ret = pxa_camera_try_bus_param(icd, f->fmt.pix.pixelformat); 934 int ret = pxa_camera_try_bus_param(icd, f->fmt.pix.pixelformat);
917 935
918 if (ret < 0) 936 if (ret < 0)
919 return ret; 937 return ret;
920 938
939 /*
940 * TODO: find a suitable supported by the SoC output format, check
941 * whether the sensor supports one of acceptable input formats.
942 */
943 cam_fmt = soc_camera_format_by_fourcc(icd, f->fmt.pix.pixelformat);
944 if (!cam_fmt)
945 return -EINVAL;
946
921 /* limit to pxa hardware capabilities */ 947 /* limit to pxa hardware capabilities */
922 if (f->fmt.pix.height < 32) 948 if (f->fmt.pix.height < 32)
923 f->fmt.pix.height = 32; 949 f->fmt.pix.height = 32;
@@ -929,6 +955,10 @@ static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd,
929 f->fmt.pix.width = 2048; 955 f->fmt.pix.width = 2048;
930 f->fmt.pix.width &= ~0x01; 956 f->fmt.pix.width &= ~0x01;
931 957
958 f->fmt.pix.bytesperline = f->fmt.pix.width *
959 DIV_ROUND_UP(cam_fmt->depth, 8);
960 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
961
932 /* limit to sensor capabilities */ 962 /* limit to sensor capabilities */
933 return icd->ops->try_fmt_cap(icd, f); 963 return icd->ops->try_fmt_cap(icd, f);
934} 964}