提交 a4e9f10b 编写于 作者: G Guennadi Liakhovetski 提交者: Mauro Carvalho Chehab

[media] V4L: atmel-isi: 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: NGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 fae00288
...@@ -94,6 +94,7 @@ struct atmel_isi { ...@@ -94,6 +94,7 @@ struct atmel_isi {
unsigned int irq; unsigned int irq;
struct isi_platform_data *pdata; struct isi_platform_data *pdata;
u16 width_flags; /* max 12 bits */
struct list_head video_buffer_list; struct list_head video_buffer_list;
struct frame_buffer *active; struct frame_buffer *active;
...@@ -647,50 +648,42 @@ static bool isi_camera_packing_supported(const struct soc_mbus_pixelfmt *fmt) ...@@ -647,50 +648,42 @@ static bool isi_camera_packing_supported(const struct soc_mbus_pixelfmt *fmt)
fmt->packing == SOC_MBUS_PACKING_EXTEND16); fmt->packing == SOC_MBUS_PACKING_EXTEND16);
} }
static unsigned long make_bus_param(struct atmel_isi *isi) #define ISI_BUS_PARAM (V4L2_MBUS_MASTER | \
{ V4L2_MBUS_HSYNC_ACTIVE_HIGH | \
unsigned long flags; V4L2_MBUS_HSYNC_ACTIVE_LOW | \
/* V4L2_MBUS_VSYNC_ACTIVE_HIGH | \
* Platform specified synchronization and pixel clock polarities are V4L2_MBUS_VSYNC_ACTIVE_LOW | \
* only a recommendation and are only used during probing. Atmel ISI V4L2_MBUS_PCLK_SAMPLE_RISING | \
* camera interface only works in master mode, i.e., uses HSYNC and V4L2_MBUS_PCLK_SAMPLE_FALLING | \
* VSYNC signals from the sensor V4L2_MBUS_DATA_ACTIVE_HIGH)
*/
flags = SOCAM_MASTER |
SOCAM_HSYNC_ACTIVE_HIGH |
SOCAM_HSYNC_ACTIVE_LOW |
SOCAM_VSYNC_ACTIVE_HIGH |
SOCAM_VSYNC_ACTIVE_LOW |
SOCAM_PCLK_SAMPLE_RISING |
SOCAM_PCLK_SAMPLE_FALLING |
SOCAM_DATA_ACTIVE_HIGH;
if (isi->pdata->data_width_flags & ISI_DATAWIDTH_10)
flags |= SOCAM_DATAWIDTH_10;
if (isi->pdata->data_width_flags & ISI_DATAWIDTH_8)
flags |= SOCAM_DATAWIDTH_8;
if (flags & SOCAM_DATAWIDTH_MASK)
return flags;
return 0;
}
static int isi_camera_try_bus_param(struct soc_camera_device *icd, static int isi_camera_try_bus_param(struct soc_camera_device *icd,
unsigned char buswidth) unsigned char buswidth)
{ {
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct atmel_isi *isi = ici->priv; struct atmel_isi *isi = ici->priv;
unsigned long camera_flags; struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
unsigned long common_flags;
int ret; int ret;
camera_flags = icd->ops->query_bus_param(icd); ret = v4l2_subdev_call(sd, video, g_mbus_config, &cfg);
ret = soc_camera_bus_param_compatible(camera_flags, if (!ret) {
make_bus_param(isi)); common_flags = soc_mbus_config_compatible(&cfg,
if (!ret) ISI_BUS_PARAM);
if (!common_flags) {
dev_warn(icd->parent,
"Flags incompatible: camera 0x%x, host 0x%x\n",
cfg.flags, ISI_BUS_PARAM);
return -EINVAL; return -EINVAL;
}
} else if (ret != -ENOIOCTLCMD) {
return ret;
}
if ((1 << (buswidth - 1)) & isi->width_flags)
return 0; return 0;
return -EINVAL;
} }
...@@ -812,59 +805,71 @@ static int isi_camera_querycap(struct soc_camera_host *ici, ...@@ -812,59 +805,71 @@ static int isi_camera_querycap(struct soc_camera_host *ici,
static int isi_camera_set_bus_param(struct soc_camera_device *icd, u32 pixfmt) static int isi_camera_set_bus_param(struct soc_camera_device *icd, u32 pixfmt)
{ {
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct atmel_isi *isi = ici->priv; struct atmel_isi *isi = ici->priv;
unsigned long bus_flags, camera_flags, common_flags; struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
unsigned long common_flags;
int ret; int ret;
u32 cfg1 = 0; u32 cfg1 = 0;
camera_flags = icd->ops->query_bus_param(icd); ret = v4l2_subdev_call(sd, video, g_mbus_config, &cfg);
if (!ret) {
bus_flags = make_bus_param(isi); common_flags = soc_mbus_config_compatible(&cfg,
common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags); ISI_BUS_PARAM);
dev_dbg(icd->parent, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n", if (!common_flags) {
camera_flags, bus_flags, common_flags); dev_warn(icd->parent,
if (!common_flags) "Flags incompatible: camera 0x%x, host 0x%x\n",
cfg.flags, ISI_BUS_PARAM);
return -EINVAL; return -EINVAL;
}
} else if (ret != -ENOIOCTLCMD) {
return ret;
} else {
common_flags = ISI_BUS_PARAM;
}
dev_dbg(icd->parent, "Flags cam: 0x%x host: 0x%x common: 0x%lx\n",
cfg.flags, ISI_BUS_PARAM, common_flags);
/* Make choises, based on platform preferences */ /* Make choises, based on platform preferences */
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 (isi->pdata->hsync_act_low) if (isi->pdata->hsync_act_low)
common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH; common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else else
common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW; common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
} }
if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) && if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
(common_flags & SOCAM_VSYNC_ACTIVE_LOW)) { (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
if (isi->pdata->vsync_act_low) if (isi->pdata->vsync_act_low)
common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH; common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else else
common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW; common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
} }
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 (isi->pdata->pclk_act_falling) if (isi->pdata->pclk_act_falling)
common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING;
else else
common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING;
} }
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);
dev_dbg(icd->parent, "Camera set_bus_param(%lx) returned %d\n", if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned %d\n",
common_flags, ret); common_flags, ret);
return ret; return ret;
} }
/* set bus param for ISI */ /* set bus param for ISI */
if (common_flags & SOCAM_HSYNC_ACTIVE_LOW) if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
cfg1 |= ISI_CFG1_HSYNC_POL_ACTIVE_LOW; cfg1 |= ISI_CFG1_HSYNC_POL_ACTIVE_LOW;
if (common_flags & SOCAM_VSYNC_ACTIVE_LOW) if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
cfg1 |= ISI_CFG1_VSYNC_POL_ACTIVE_LOW; cfg1 |= ISI_CFG1_VSYNC_POL_ACTIVE_LOW;
if (common_flags & SOCAM_PCLK_SAMPLE_FALLING) if (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
cfg1 |= ISI_CFG1_PIXCLK_POL_ACTIVE_FALLING; cfg1 |= ISI_CFG1_PIXCLK_POL_ACTIVE_FALLING;
if (isi->pdata->has_emb_sync) if (isi->pdata->has_emb_sync)
...@@ -983,6 +988,11 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) ...@@ -983,6 +988,11 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
goto err_ioremap; goto err_ioremap;
} }
if (pdata->data_width_flags & ISI_DATAWIDTH_8)
isi->width_flags = 1 << 7;
if (pdata->data_width_flags & ISI_DATAWIDTH_10)
isi->width_flags |= 1 << 9;
isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS); isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册