aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2011-05-18 05:49:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-20 11:06:46 -0400
commitd2dcad49bc346054b49bd40fd96f397fec695a0f (patch)
tree2aefcd96625a494c842938daa59c9dbfd6a7f1d6 /drivers/media
parente23b961dd1206aceaad28233212f3d506595432f (diff)
[media] V4L: soc-camera: a missing mediabus code -> fourcc translation is not critical
soc_mbus_get_fmtdesc() returning NULL means only, that no standard mediabus code -> fourcc conversion is known, this shouldn't be treated as an error by drivers. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/mx3_camera.c24
-rw-r--r--drivers/media/video/omap1_camera.c2
-rw-r--r--drivers/media/video/pxa_camera.c8
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c4
-rw-r--r--drivers/media/video/soc_camera.c9
5 files changed, 21 insertions, 26 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index 3e5435b539ba..c7680eb83664 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -688,8 +688,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
688 688
689 fmt = soc_mbus_get_fmtdesc(code); 689 fmt = soc_mbus_get_fmtdesc(code);
690 if (!fmt) { 690 if (!fmt) {
691 dev_err(icd->dev.parent, 691 dev_warn(icd->dev.parent,
692 "Invalid format code #%u: %d\n", idx, code); 692 "Unsupported format code #%u: %d\n", idx, code);
693 return 0; 693 return 0;
694 } 694 }
695 695
@@ -742,13 +742,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
742 742
743static void configure_geometry(struct mx3_camera_dev *mx3_cam, 743static void configure_geometry(struct mx3_camera_dev *mx3_cam,
744 unsigned int width, unsigned int height, 744 unsigned int width, unsigned int height,
745 enum v4l2_mbus_pixelcode code) 745 const struct soc_mbus_pixelfmt *fmt)
746{ 746{
747 u32 ctrl, width_field, height_field; 747 u32 ctrl, width_field, height_field;
748 const struct soc_mbus_pixelfmt *fmt;
749
750 fmt = soc_mbus_get_fmtdesc(code);
751 BUG_ON(!fmt);
752 748
753 if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) { 749 if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) {
754 /* 750 /*
@@ -806,8 +802,8 @@ static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam)
806 */ 802 */
807static inline void stride_align(__u32 *width) 803static inline void stride_align(__u32 *width)
808{ 804{
809 if (((*width + 7) & ~7) < 4096) 805 if (ALIGN(*width, 8) < 4096)
810 *width = (*width + 7) & ~7; 806 *width = ALIGN(*width, 8);
811 else 807 else
812 *width = *width & ~7; 808 *width = *width & ~7;
813} 809}
@@ -833,11 +829,14 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
833 if (ret < 0) 829 if (ret < 0)
834 return ret; 830 return ret;
835 831
836 /* The capture device might have changed its output */ 832 /* The capture device might have changed its output sizes */
837 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); 833 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
838 if (ret < 0) 834 if (ret < 0)
839 return ret; 835 return ret;
840 836
837 if (mf.code != icd->current_fmt->code)
838 return -EINVAL;
839
841 if (mf.width & 7) { 840 if (mf.width & 7) {
842 /* Ouch! We can only handle 8-byte aligned width... */ 841 /* Ouch! We can only handle 8-byte aligned width... */
843 stride_align(&mf.width); 842 stride_align(&mf.width);
@@ -847,7 +846,8 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
847 } 846 }
848 847
849 if (mf.width != icd->user_width || mf.height != icd->user_height) 848 if (mf.width != icd->user_width || mf.height != icd->user_height)
850 configure_geometry(mx3_cam, mf.width, mf.height, mf.code); 849 configure_geometry(mx3_cam, mf.width, mf.height,
850 icd->current_fmt->host_fmt);
851 851
852 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n", 852 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n",
853 mf.width, mf.height); 853 mf.width, mf.height);
@@ -885,7 +885,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
885 * mxc_v4l2_s_fmt() 885 * mxc_v4l2_s_fmt()
886 */ 886 */
887 887
888 configure_geometry(mx3_cam, pix->width, pix->height, xlate->code); 888 configure_geometry(mx3_cam, pix->width, pix->height, xlate->host_fmt);
889 889
890 mf.width = pix->width; 890 mf.width = pix->width;
891 mf.height = pix->height; 891 mf.height = pix->height;
diff --git a/drivers/media/video/omap1_camera.c b/drivers/media/video/omap1_camera.c
index fe577a9632b4..e7cfc85b0a1c 100644
--- a/drivers/media/video/omap1_camera.c
+++ b/drivers/media/video/omap1_camera.c
@@ -1082,7 +1082,7 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd,
1082 1082
1083 fmt = soc_mbus_get_fmtdesc(code); 1083 fmt = soc_mbus_get_fmtdesc(code);
1084 if (!fmt) { 1084 if (!fmt) {
1085 dev_err(dev, "%s: invalid format code #%d: %d\n", __func__, 1085 dev_warn(dev, "%s: unsupported format code #%d: %d\n", __func__,
1086 idx, code); 1086 idx, code);
1087 return 0; 1087 return 0;
1088 } 1088 }
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index c1ee09a043ba..b42bfa5ccdf2 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -1155,15 +1155,11 @@ static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
1155 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 1155 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
1156 struct pxa_camera_dev *pcdev = ici->priv; 1156 struct pxa_camera_dev *pcdev = ici->priv;
1157 unsigned long bus_flags, camera_flags, common_flags; 1157 unsigned long bus_flags, camera_flags, common_flags;
1158 const struct soc_mbus_pixelfmt *fmt;
1159 int ret; 1158 int ret;
1160 struct pxa_cam *cam = icd->host_priv; 1159 struct pxa_cam *cam = icd->host_priv;
1161 1160
1162 fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code); 1161 ret = test_platform_param(pcdev, icd->current_fmt->host_fmt->bits_per_sample,
1163 if (!fmt) 1162 &bus_flags);
1164 return -EINVAL;
1165
1166 ret = test_platform_param(pcdev, fmt->bits_per_sample, &bus_flags);
1167 if (ret < 0) 1163 if (ret < 0)
1168 return ret; 1164 return ret;
1169 1165
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index bf10ffcc5783..3ae5c9c58cba 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -917,8 +917,8 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
917 917
918 fmt = soc_mbus_get_fmtdesc(code); 918 fmt = soc_mbus_get_fmtdesc(code);
919 if (!fmt) { 919 if (!fmt) {
920 dev_err(dev, "Invalid format code #%u: %d\n", idx, code); 920 dev_warn(dev, "unsupported format code #%u: %d\n", idx, code);
921 return -EINVAL; 921 return 0;
922 } 922 }
923 923
924 if (!pcdev->pdata->csi2_dev) { 924 if (!pcdev->pdata->csi2_dev) {
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 3fb533c4d334..398864370267 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -363,8 +363,6 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
363 if (!icd->user_formats) 363 if (!icd->user_formats)
364 return -ENOMEM; 364 return -ENOMEM;
365 365
366 icd->num_user_formats = fmts;
367
368 dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts); 366 dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts);
369 367
370 /* Second pass - actually fill data formats */ 368 /* Second pass - actually fill data formats */
@@ -372,9 +370,10 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
372 for (i = 0; i < raw_fmts; i++) 370 for (i = 0; i < raw_fmts; i++)
373 if (!ici->ops->get_formats) { 371 if (!ici->ops->get_formats) {
374 v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code); 372 v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code);
375 icd->user_formats[i].host_fmt = 373 icd->user_formats[fmts].host_fmt =
376 soc_mbus_get_fmtdesc(code); 374 soc_mbus_get_fmtdesc(code);
377 icd->user_formats[i].code = code; 375 if (icd->user_formats[fmts].host_fmt)
376 icd->user_formats[fmts++].code = code;
378 } else { 377 } else {
379 ret = ici->ops->get_formats(icd, i, 378 ret = ici->ops->get_formats(icd, i,
380 &icd->user_formats[fmts]); 379 &icd->user_formats[fmts]);
@@ -383,12 +382,12 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
383 fmts += ret; 382 fmts += ret;
384 } 383 }
385 384
385 icd->num_user_formats = fmts;
386 icd->current_fmt = &icd->user_formats[0]; 386 icd->current_fmt = &icd->user_formats[0];
387 387
388 return 0; 388 return 0;
389 389
390egfmt: 390egfmt:
391 icd->num_user_formats = 0;
392 vfree(icd->user_formats); 391 vfree(icd->user_formats);
393 return ret; 392 return ret;
394} 393}