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

[media] V4L: mx2_camera: convert to the new mbus-config subdev operations

Switch from soc-camera specific .{query,set}_bus_param() to V4L2
subdevice .[gs]_mbus_config() operations.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8acbfd33
...@@ -686,16 +686,15 @@ static void mx2_camera_init_videobuf(struct videobuf_queue *q, ...@@ -686,16 +686,15 @@ static void mx2_camera_init_videobuf(struct videobuf_queue *q,
icd, &icd->video_lock); icd, &icd->video_lock);
} }
#define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \ #define MX2_BUS_FLAGS (V4L2_MBUS_MASTER | \
SOCAM_MASTER | \ V4L2_MBUS_VSYNC_ACTIVE_HIGH | \
SOCAM_VSYNC_ACTIVE_HIGH | \ V4L2_MBUS_VSYNC_ACTIVE_LOW | \
SOCAM_VSYNC_ACTIVE_LOW | \ V4L2_MBUS_HSYNC_ACTIVE_HIGH | \
SOCAM_HSYNC_ACTIVE_HIGH | \ V4L2_MBUS_HSYNC_ACTIVE_LOW | \
SOCAM_HSYNC_ACTIVE_LOW | \ V4L2_MBUS_PCLK_SAMPLE_RISING | \
SOCAM_PCLK_SAMPLE_RISING | \ V4L2_MBUS_PCLK_SAMPLE_FALLING | \
SOCAM_PCLK_SAMPLE_FALLING | \ V4L2_MBUS_DATA_ACTIVE_HIGH | \
SOCAM_DATA_ACTIVE_HIGH | \ V4L2_MBUS_DATA_ACTIVE_LOW)
SOCAM_DATA_ACTIVE_LOW)
static int mx27_camera_emma_prp_reset(struct mx2_camera_dev *pcdev) static int mx27_camera_emma_prp_reset(struct mx2_camera_dev *pcdev)
{ {
...@@ -770,46 +769,59 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, ...@@ -770,46 +769,59 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd,
static int mx2_camera_set_bus_param(struct soc_camera_device *icd, static int mx2_camera_set_bus_param(struct soc_camera_device *icd,
__u32 pixfmt) __u32 pixfmt)
{ {
struct soc_camera_host *ici = struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
to_soc_camera_host(icd->parent); struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct mx2_camera_dev *pcdev = ici->priv; struct mx2_camera_dev *pcdev = ici->priv;
unsigned long camera_flags, common_flags; struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
int ret = 0; unsigned long common_flags;
int ret;
int bytesperline; int bytesperline;
u32 csicr1 = pcdev->csicr1; u32 csicr1 = pcdev->csicr1;
camera_flags = icd->ops->query_bus_param(icd); ret = v4l2_subdev_call(sd, video, g_mbus_config, &cfg);
if (!ret) {
common_flags = soc_camera_bus_param_compatible(camera_flags, common_flags = soc_mbus_config_compatible(&cfg, MX2_BUS_FLAGS);
MX2_BUS_FLAGS); if (!common_flags) {
if (!common_flags) dev_warn(icd->parent,
return -EINVAL; "Flags incompatible: camera 0x%x, host 0x%x\n",
cfg.flags, MX2_BUS_FLAGS);
return -EINVAL;
}
} else if (ret != -ENOIOCTLCMD) {
return ret;
} else {
common_flags = MX2_BUS_FLAGS;
}
if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) && if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
(common_flags & SOCAM_HSYNC_ACTIVE_LOW)) { (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
if (pcdev->platform_flags & MX2_CAMERA_HSYNC_HIGH) if (pcdev->platform_flags & MX2_CAMERA_HSYNC_HIGH)
common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW; common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
else else
common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH; common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
} }
if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) && if ((common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) &&
(common_flags & SOCAM_PCLK_SAMPLE_FALLING)) { (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)) {
if (pcdev->platform_flags & MX2_CAMERA_PCLK_SAMPLE_RISING) if (pcdev->platform_flags & MX2_CAMERA_PCLK_SAMPLE_RISING)
common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING;
else else
common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING;
} }
ret = icd->ops->set_bus_param(icd, common_flags); cfg.flags = common_flags;
if (ret < 0) ret = v4l2_subdev_call(sd, video, s_mbus_config, &cfg);
if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned %d\n",
common_flags, ret);
return ret; return ret;
}
if (common_flags & SOCAM_PCLK_SAMPLE_RISING) if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
csicr1 |= CSICR1_REDGE; csicr1 |= CSICR1_REDGE;
if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH) if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
csicr1 |= CSICR1_SOF_POL; csicr1 |= CSICR1_SOF_POL;
if (common_flags & SOCAM_HSYNC_ACTIVE_HIGH) if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
csicr1 |= CSICR1_HSYNC_POL; csicr1 |= CSICR1_HSYNC_POL;
if (pcdev->platform_flags & MX2_CAMERA_SWAP16) if (pcdev->platform_flags & MX2_CAMERA_SWAP16)
csicr1 |= CSICR1_SWAP16_EN; csicr1 |= CSICR1_SWAP16_EN;
......
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