Commit d2dcad49 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

[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: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e23b961d
...@@ -688,8 +688,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id ...@@ -688,8 +688,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
fmt = soc_mbus_get_fmtdesc(code); fmt = soc_mbus_get_fmtdesc(code);
if (!fmt) { if (!fmt) {
dev_err(icd->dev.parent, dev_warn(icd->dev.parent,
"Invalid format code #%u: %d\n", idx, code); "Unsupported format code #%u: %d\n", idx, code);
return 0; return 0;
} }
...@@ -742,13 +742,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id ...@@ -742,13 +742,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
static void configure_geometry(struct mx3_camera_dev *mx3_cam, static void configure_geometry(struct mx3_camera_dev *mx3_cam,
unsigned int width, unsigned int height, unsigned int width, unsigned int height,
enum v4l2_mbus_pixelcode code) const struct soc_mbus_pixelfmt *fmt)
{ {
u32 ctrl, width_field, height_field; u32 ctrl, width_field, height_field;
const struct soc_mbus_pixelfmt *fmt;
fmt = soc_mbus_get_fmtdesc(code);
BUG_ON(!fmt);
if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) { if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) {
/* /*
...@@ -806,8 +802,8 @@ static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam) ...@@ -806,8 +802,8 @@ static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam)
*/ */
static inline void stride_align(__u32 *width) static inline void stride_align(__u32 *width)
{ {
if (((*width + 7) & ~7) < 4096) if (ALIGN(*width, 8) < 4096)
*width = (*width + 7) & ~7; *width = ALIGN(*width, 8);
else else
*width = *width & ~7; *width = *width & ~7;
} }
...@@ -833,11 +829,14 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd, ...@@ -833,11 +829,14 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
if (ret < 0) if (ret < 0)
return ret; return ret;
/* The capture device might have changed its output */ /* The capture device might have changed its output sizes */
ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (mf.code != icd->current_fmt->code)
return -EINVAL;
if (mf.width & 7) { if (mf.width & 7) {
/* Ouch! We can only handle 8-byte aligned width... */ /* Ouch! We can only handle 8-byte aligned width... */
stride_align(&mf.width); stride_align(&mf.width);
...@@ -847,7 +846,8 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd, ...@@ -847,7 +846,8 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
} }
if (mf.width != icd->user_width || mf.height != icd->user_height) if (mf.width != icd->user_width || mf.height != icd->user_height)
configure_geometry(mx3_cam, mf.width, mf.height, mf.code); configure_geometry(mx3_cam, mf.width, mf.height,
icd->current_fmt->host_fmt);
dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n", dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n",
mf.width, mf.height); mf.width, mf.height);
...@@ -885,7 +885,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd, ...@@ -885,7 +885,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
* mxc_v4l2_s_fmt() * mxc_v4l2_s_fmt()
*/ */
configure_geometry(mx3_cam, pix->width, pix->height, xlate->code); configure_geometry(mx3_cam, pix->width, pix->height, xlate->host_fmt);
mf.width = pix->width; mf.width = pix->width;
mf.height = pix->height; mf.height = pix->height;
......
...@@ -1082,7 +1082,7 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd, ...@@ -1082,7 +1082,7 @@ static int omap1_cam_get_formats(struct soc_camera_device *icd,
fmt = soc_mbus_get_fmtdesc(code); fmt = soc_mbus_get_fmtdesc(code);
if (!fmt) { if (!fmt) {
dev_err(dev, "%s: invalid format code #%d: %d\n", __func__, dev_warn(dev, "%s: unsupported format code #%d: %d\n", __func__,
idx, code); idx, code);
return 0; return 0;
} }
......
...@@ -1155,15 +1155,11 @@ static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) ...@@ -1155,15 +1155,11 @@ static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv; struct pxa_camera_dev *pcdev = ici->priv;
unsigned long bus_flags, camera_flags, common_flags; unsigned long bus_flags, camera_flags, common_flags;
const struct soc_mbus_pixelfmt *fmt;
int ret; int ret;
struct pxa_cam *cam = icd->host_priv; struct pxa_cam *cam = icd->host_priv;
fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code); ret = test_platform_param(pcdev, icd->current_fmt->host_fmt->bits_per_sample,
if (!fmt) &bus_flags);
return -EINVAL;
ret = test_platform_param(pcdev, fmt->bits_per_sample, &bus_flags);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -917,8 +917,8 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int ...@@ -917,8 +917,8 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
fmt = soc_mbus_get_fmtdesc(code); fmt = soc_mbus_get_fmtdesc(code);
if (!fmt) { if (!fmt) {
dev_err(dev, "Invalid format code #%u: %d\n", idx, code); dev_warn(dev, "unsupported format code #%u: %d\n", idx, code);
return -EINVAL; return 0;
} }
if (!pcdev->pdata->csi2_dev) { if (!pcdev->pdata->csi2_dev) {
......
...@@ -363,8 +363,6 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) ...@@ -363,8 +363,6 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
if (!icd->user_formats) if (!icd->user_formats)
return -ENOMEM; return -ENOMEM;
icd->num_user_formats = fmts;
dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts); dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts);
/* Second pass - actually fill data formats */ /* Second pass - actually fill data formats */
...@@ -372,9 +370,10 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) ...@@ -372,9 +370,10 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
for (i = 0; i < raw_fmts; i++) for (i = 0; i < raw_fmts; i++)
if (!ici->ops->get_formats) { if (!ici->ops->get_formats) {
v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code); v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code);
icd->user_formats[i].host_fmt = icd->user_formats[fmts].host_fmt =
soc_mbus_get_fmtdesc(code); soc_mbus_get_fmtdesc(code);
icd->user_formats[i].code = code; if (icd->user_formats[fmts].host_fmt)
icd->user_formats[fmts++].code = code;
} else { } else {
ret = ici->ops->get_formats(icd, i, ret = ici->ops->get_formats(icd, i,
&icd->user_formats[fmts]); &icd->user_formats[fmts]);
...@@ -383,12 +382,12 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) ...@@ -383,12 +382,12 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
fmts += ret; fmts += ret;
} }
icd->num_user_formats = fmts;
icd->current_fmt = &icd->user_formats[0]; icd->current_fmt = &icd->user_formats[0];
return 0; return 0;
egfmt: egfmt:
icd->num_user_formats = 0;
vfree(icd->user_formats); vfree(icd->user_formats);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment