Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Guennadi Liakhovetski and committed by
Mauro Carvalho Chehab
d2dcad49 e23b961d

+21 -26
+12 -12
drivers/media/video/mx3_camera.c
··· 688 688 689 689 fmt = soc_mbus_get_fmtdesc(code); 690 690 if (!fmt) { 691 - dev_err(icd->dev.parent, 692 - "Invalid format code #%u: %d\n", idx, code); 691 + dev_warn(icd->dev.parent, 692 + "Unsupported format code #%u: %d\n", idx, code); 693 693 return 0; 694 694 } 695 695 ··· 742 742 743 743 static void configure_geometry(struct mx3_camera_dev *mx3_cam, 744 744 unsigned int width, unsigned int height, 745 - enum v4l2_mbus_pixelcode code) 745 + const struct soc_mbus_pixelfmt *fmt) 746 746 { 747 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 749 if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) { 754 750 /* ··· 802 806 */ 803 807 static inline void stride_align(__u32 *width) 804 808 { 805 - if (((*width + 7) & ~7) < 4096) 806 - *width = (*width + 7) & ~7; 809 + if (ALIGN(*width, 8) < 4096) 810 + *width = ALIGN(*width, 8); 807 811 else 808 812 *width = *width & ~7; 809 813 } ··· 829 833 if (ret < 0) 830 834 return ret; 831 835 832 - /* The capture device might have changed its output */ 836 + /* The capture device might have changed its output sizes */ 833 837 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); 834 838 if (ret < 0) 835 839 return ret; 840 + 841 + if (mf.code != icd->current_fmt->code) 842 + return -EINVAL; 836 843 837 844 if (mf.width & 7) { 838 845 /* Ouch! We can only handle 8-byte aligned width... */ ··· 846 847 } 847 848 848 849 if (mf.width != icd->user_width || mf.height != icd->user_height) 849 - configure_geometry(mx3_cam, mf.width, mf.height, mf.code); 850 + configure_geometry(mx3_cam, mf.width, mf.height, 851 + icd->current_fmt->host_fmt); 850 852 851 853 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n", 852 854 mf.width, mf.height); ··· 885 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 890 mf.width = pix->width; 891 891 mf.height = pix->height;
+1 -1
drivers/media/video/omap1_camera.c
··· 1082 1082 1083 1083 fmt = soc_mbus_get_fmtdesc(code); 1084 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 1086 idx, code); 1087 1087 return 0; 1088 1088 }
+2 -6
drivers/media/video/pxa_camera.c
··· 1155 1155 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 1156 1156 struct pxa_camera_dev *pcdev = ici->priv; 1157 1157 unsigned long bus_flags, camera_flags, common_flags; 1158 - const struct soc_mbus_pixelfmt *fmt; 1159 1158 int ret; 1160 1159 struct pxa_cam *cam = icd->host_priv; 1161 1160 1162 - fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code); 1163 - if (!fmt) 1164 - return -EINVAL; 1165 - 1166 - ret = test_platform_param(pcdev, fmt->bits_per_sample, &bus_flags); 1161 + ret = test_platform_param(pcdev, icd->current_fmt->host_fmt->bits_per_sample, 1162 + &bus_flags); 1167 1163 if (ret < 0) 1168 1164 return ret; 1169 1165
+2 -2
drivers/media/video/sh_mobile_ceu_camera.c
··· 917 917 918 918 fmt = soc_mbus_get_fmtdesc(code); 919 919 if (!fmt) { 920 - dev_err(dev, "Invalid format code #%u: %d\n", idx, code); 921 - return -EINVAL; 920 + dev_warn(dev, "unsupported format code #%u: %d\n", idx, code); 921 + return 0; 922 922 } 923 923 924 924 if (!pcdev->pdata->csi2_dev) {
+4 -5
drivers/media/video/soc_camera.c
··· 363 363 if (!icd->user_formats) 364 364 return -ENOMEM; 365 365 366 - icd->num_user_formats = fmts; 367 - 368 366 dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts); 369 367 370 368 /* Second pass - actually fill data formats */ ··· 370 372 for (i = 0; i < raw_fmts; i++) 371 373 if (!ici->ops->get_formats) { 372 374 v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code); 373 - icd->user_formats[i].host_fmt = 375 + icd->user_formats[fmts].host_fmt = 374 376 soc_mbus_get_fmtdesc(code); 375 - icd->user_formats[i].code = code; 377 + if (icd->user_formats[fmts].host_fmt) 378 + icd->user_formats[fmts++].code = code; 376 379 } else { 377 380 ret = ici->ops->get_formats(icd, i, 378 381 &icd->user_formats[fmts]); ··· 382 383 fmts += ret; 383 384 } 384 385 386 + icd->num_user_formats = fmts; 385 387 icd->current_fmt = &icd->user_formats[0]; 386 388 387 389 return 0; 388 390 389 391 egfmt: 390 - icd->num_user_formats = 0; 391 392 vfree(icd->user_formats); 392 393 return ret; 393 394 }