diff options
| author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-07-27 11:30:21 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-03 16:27:43 -0400 |
| commit | 8acbfd3306195f85c2255ecd9b2337cb2ac4c532 (patch) | |
| tree | 8d188a25ea34b457337bec1eaaefd9327cfcacce | |
| parent | a4e9f10ba9b788a2254cf26d3f0a22555d439ea4 (diff) | |
[media] V4L: mx1_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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
| -rw-r--r-- | drivers/media/video/mx1_camera.c | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c index 087db12a3a67..18e94c7d2be8 100644 --- a/drivers/media/video/mx1_camera.c +++ b/drivers/media/video/mx1_camera.c | |||
| @@ -78,11 +78,10 @@ | |||
| 78 | #define CSI_IRQ_MASK (CSISR_SFF_OR_INT | CSISR_RFF_OR_INT | \ | 78 | #define CSI_IRQ_MASK (CSISR_SFF_OR_INT | CSISR_RFF_OR_INT | \ |
| 79 | CSISR_STATFF_INT | CSISR_RXFF_INT | CSISR_SOF_INT) | 79 | CSISR_STATFF_INT | CSISR_RXFF_INT | CSISR_SOF_INT) |
| 80 | 80 | ||
| 81 | #define CSI_BUS_FLAGS (SOCAM_MASTER | SOCAM_HSYNC_ACTIVE_HIGH | \ | 81 | #define CSI_BUS_FLAGS (V4L2_MBUS_MASTER | V4L2_MBUS_HSYNC_ACTIVE_HIGH | \ |
| 82 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW | \ | 82 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW | \ |
| 83 | SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING | \ | 83 | V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING | \ |
| 84 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW | \ | 84 | V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_LOW) |
| 85 | SOCAM_DATAWIDTH_8) | ||
| 86 | 85 | ||
| 87 | #define MAX_VIDEO_MEM 16 /* Video memory limit in megabytes */ | 86 | #define MAX_VIDEO_MEM 16 /* Video memory limit in megabytes */ |
| 88 | 87 | ||
| @@ -490,59 +489,73 @@ static int mx1_camera_set_crop(struct soc_camera_device *icd, | |||
| 490 | 489 | ||
| 491 | static int mx1_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) | 490 | static int mx1_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) |
| 492 | { | 491 | { |
| 492 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | ||
| 493 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 493 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
| 494 | struct mx1_camera_dev *pcdev = ici->priv; | 494 | struct mx1_camera_dev *pcdev = ici->priv; |
| 495 | unsigned long camera_flags, common_flags; | 495 | struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,}; |
| 496 | unsigned long common_flags; | ||
| 496 | unsigned int csicr1; | 497 | unsigned int csicr1; |
| 497 | int ret; | 498 | int ret; |
| 498 | 499 | ||
| 499 | camera_flags = icd->ops->query_bus_param(icd); | ||
| 500 | |||
| 501 | /* MX1 supports only 8bit buswidth */ | 500 | /* MX1 supports only 8bit buswidth */ |
| 502 | common_flags = soc_camera_bus_param_compatible(camera_flags, | 501 | ret = v4l2_subdev_call(sd, video, g_mbus_config, &cfg); |
| 503 | CSI_BUS_FLAGS); | 502 | if (!ret) { |
| 504 | if (!common_flags) | 503 | common_flags = soc_mbus_config_compatible(&cfg, CSI_BUS_FLAGS); |
| 505 | return -EINVAL; | 504 | if (!common_flags) { |
| 505 | dev_warn(icd->parent, | ||
| 506 | "Flags incompatible: camera 0x%x, host 0x%x\n", | ||
| 507 | cfg.flags, CSI_BUS_FLAGS); | ||
| 508 | return -EINVAL; | ||
| 509 | } | ||
| 510 | } else if (ret != -ENOIOCTLCMD) { | ||
| 511 | return ret; | ||
| 512 | } else { | ||
| 513 | common_flags = CSI_BUS_FLAGS; | ||
| 514 | } | ||
| 506 | 515 | ||
| 507 | /* Make choises, based on platform choice */ | 516 | /* Make choises, based on platform choice */ |
| 508 | if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) && | 517 | if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) && |
| 509 | (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) { | 518 | (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) { |
| 510 | if (!pcdev->pdata || | 519 | if (!pcdev->pdata || |
| 511 | pcdev->pdata->flags & MX1_CAMERA_VSYNC_HIGH) | 520 | pcdev->pdata->flags & MX1_CAMERA_VSYNC_HIGH) |
| 512 | common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW; | 521 | common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW; |
| 513 | else | 522 | else |
| 514 | common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH; | 523 | common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH; |
| 515 | } | 524 | } |
| 516 | 525 | ||
| 517 | if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) && | 526 | if ((common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) && |
| 518 | (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) { | 527 | (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)) { |
| 519 | if (!pcdev->pdata || | 528 | if (!pcdev->pdata || |
| 520 | pcdev->pdata->flags & MX1_CAMERA_PCLK_RISING) | 529 | pcdev->pdata->flags & MX1_CAMERA_PCLK_RISING) |
| 521 | common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; | 530 | common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING; |
| 522 | else | 531 | else |
| 523 | common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; | 532 | common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING; |
| 524 | } | 533 | } |
| 525 | 534 | ||
| 526 | if ((common_flags & SOCAM_DATA_ACTIVE_HIGH) && | 535 | if ((common_flags & V4L2_MBUS_DATA_ACTIVE_HIGH) && |
| 527 | (common_flags & SOCAM_DATA_ACTIVE_LOW)) { | 536 | (common_flags & V4L2_MBUS_DATA_ACTIVE_LOW)) { |
| 528 | if (!pcdev->pdata || | 537 | if (!pcdev->pdata || |
| 529 | pcdev->pdata->flags & MX1_CAMERA_DATA_HIGH) | 538 | pcdev->pdata->flags & MX1_CAMERA_DATA_HIGH) |
| 530 | common_flags &= ~SOCAM_DATA_ACTIVE_LOW; | 539 | common_flags &= ~V4L2_MBUS_DATA_ACTIVE_LOW; |
| 531 | else | 540 | else |
| 532 | common_flags &= ~SOCAM_DATA_ACTIVE_HIGH; | 541 | common_flags &= ~V4L2_MBUS_DATA_ACTIVE_HIGH; |
| 533 | } | 542 | } |
| 534 | 543 | ||
| 535 | ret = icd->ops->set_bus_param(icd, common_flags); | 544 | cfg.flags = common_flags; |
| 536 | if (ret < 0) | 545 | ret = v4l2_subdev_call(sd, video, s_mbus_config, &cfg); |
| 546 | if (ret < 0 && ret != -ENOIOCTLCMD) { | ||
| 547 | dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned %d\n", | ||
| 548 | common_flags, ret); | ||
| 537 | return ret; | 549 | return ret; |
| 550 | } | ||
| 538 | 551 | ||
| 539 | csicr1 = __raw_readl(pcdev->base + CSICR1); | 552 | csicr1 = __raw_readl(pcdev->base + CSICR1); |
| 540 | 553 | ||
| 541 | if (common_flags & SOCAM_PCLK_SAMPLE_RISING) | 554 | if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) |
| 542 | csicr1 |= CSICR1_REDGE; | 555 | csicr1 |= CSICR1_REDGE; |
| 543 | if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH) | 556 | if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) |
| 544 | csicr1 |= CSICR1_SOF_POL; | 557 | csicr1 |= CSICR1_SOF_POL; |
| 545 | if (common_flags & SOCAM_DATA_ACTIVE_LOW) | 558 | if (common_flags & V4L2_MBUS_DATA_ACTIVE_LOW) |
| 546 | csicr1 |= CSICR1_DATA_POL; | 559 | csicr1 |= CSICR1_DATA_POL; |
| 547 | 560 | ||
| 548 | __raw_writel(csicr1, pcdev->base + CSICR1); | 561 | __raw_writel(csicr1, pcdev->base + CSICR1); |
