Skip to content

Commit

Permalink
V4L/DVB (12533): soc-camera: Use video device object for output in ho…
Browse files Browse the repository at this point in the history
…st drivers

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Sep 19, 2009
1 parent 2aa58db commit 0166b74
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 89 deletions.
38 changes: 21 additions & 17 deletions drivers/media/video/mx1_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
while (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
(*count)--;

dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size);
dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size);

return 0;
}
Expand All @@ -147,7 +147,7 @@ static void free_buffer(struct videobuf_queue *vq, struct mx1_buffer *buf)

BUG_ON(in_interrupt());

dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

/* This waits until this buffer is out of danger, i.e., until it is no
Expand All @@ -165,7 +165,7 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
int ret;

dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

/* Added list head initialization on alloc */
Expand Down Expand Up @@ -216,10 +216,11 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
{
struct videobuf_buffer *vbuf = &pcdev->active->vb;
struct device *dev = pcdev->icd->dev.parent;
int ret;

if (unlikely(!pcdev->active)) {
dev_err(pcdev->icd->dev.parent, "DMA End IRQ with no active buffer\n");
dev_err(dev, "DMA End IRQ with no active buffer\n");
return -EFAULT;
}

Expand All @@ -229,7 +230,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
vbuf->size, pcdev->res->start +
CSIRXR, DMA_MODE_READ);
if (unlikely(ret))
dev_err(pcdev->icd->dev.parent, "Failed to setup DMA sg list\n");
dev_err(dev, "Failed to setup DMA sg list\n");

return ret;
}
Expand All @@ -243,7 +244,7 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq,
struct mx1_camera_dev *pcdev = ici->priv;
struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);

dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

list_add_tail(&vb->queue, &pcdev->capture);
Expand All @@ -270,22 +271,23 @@ static void mx1_videobuf_release(struct videobuf_queue *vq,
struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
#ifdef DEBUG
struct soc_camera_device *icd = vq->priv_data;
struct device *dev = icd->dev.parent;

dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

switch (vb->state) {
case VIDEOBUF_ACTIVE:
dev_dbg(&icd->dev, "%s (active)\n", __func__);
dev_dbg(dev, "%s (active)\n", __func__);
break;
case VIDEOBUF_QUEUED:
dev_dbg(&icd->dev, "%s (queued)\n", __func__);
dev_dbg(dev, "%s (queued)\n", __func__);
break;
case VIDEOBUF_PREPARED:
dev_dbg(&icd->dev, "%s (prepared)\n", __func__);
dev_dbg(dev, "%s (prepared)\n", __func__);
break;
default:
dev_dbg(&icd->dev, "%s (unknown)\n", __func__);
dev_dbg(dev, "%s (unknown)\n", __func__);
break;
}
#endif
Expand Down Expand Up @@ -325,6 +327,7 @@ static void mx1_camera_wakeup(struct mx1_camera_dev *pcdev,
static void mx1_camera_dma_irq(int channel, void *data)
{
struct mx1_camera_dev *pcdev = data;
struct device *dev = pcdev->icd->dev.parent;
struct mx1_buffer *buf;
struct videobuf_buffer *vb;
unsigned long flags;
Expand All @@ -334,14 +337,14 @@ static void mx1_camera_dma_irq(int channel, void *data)
imx_dma_disable(channel);

if (unlikely(!pcdev->active)) {
dev_err(pcdev->icd->dev.parent, "DMA End IRQ with no active buffer\n");
dev_err(dev, "DMA End IRQ with no active buffer\n");
goto out;
}

vb = &pcdev->active->vb;
buf = container_of(vb, struct mx1_buffer, vb);
WARN_ON(buf->inwork || list_empty(&vb->queue));
dev_dbg(pcdev->icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

mx1_camera_wakeup(pcdev, vb, buf);
Expand Down Expand Up @@ -381,8 +384,9 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
* they get a nice Oops */
div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;

dev_dbg(pcdev->icd->dev.parent, "System clock %lukHz, target freq %dkHz, "
"divisor %lu\n", lcdclk / 1000, mclk / 1000, div);
dev_dbg(pcdev->icd->dev.parent,
"System clock %lukHz, target freq %dkHz, divisor %lu\n",
lcdclk / 1000, mclk / 1000, div);

return div;
}
Expand Down Expand Up @@ -428,7 +432,7 @@ static int mx1_camera_add_device(struct soc_camera_device *icd)
goto ebusy;
}

dev_info(&icd->dev, "MX1 Camera driver attached to camera %d\n",
dev_info(icd->dev.parent, "MX1 Camera driver attached to camera %d\n",
icd->devnum);

mx1_camera_activate(pcdev);
Expand All @@ -454,7 +458,7 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd)
/* Stop DMA engine */
imx_dma_disable(pcdev->dma_chan);

dev_info(&icd->dev, "MX1 Camera driver detached from camera %d\n",
dev_info(icd->dev.parent, "MX1 Camera driver detached from camera %d\n",
icd->devnum);

mx1_camera_deactivate(pcdev);
Expand Down
46 changes: 27 additions & 19 deletions drivers/media/video/mx3_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void free_buffer(struct videobuf_queue *vq, struct mx3_camera_buffer *buf

BUG_ON(in_interrupt());

dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);

/*
Expand Down Expand Up @@ -375,7 +375,8 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
spin_unlock_irq(&mx3_cam->lock);

cookie = txd->tx_submit(txd);
dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg));
dev_dbg(icd->dev.parent, "Submitted cookie %d DMA 0x%08x\n",
cookie, sg_dma_address(&buf->sg));

spin_lock_irq(&mx3_cam->lock);

Expand All @@ -402,9 +403,10 @@ static void mx3_videobuf_release(struct videobuf_queue *vq,
container_of(vb, struct mx3_camera_buffer, vb);
unsigned long flags;

dev_dbg(&icd->dev, "Release%s DMA 0x%08x (state %d), queue %sempty\n",
dev_dbg(icd->dev.parent,
"Release%s DMA 0x%08x (state %d), queue %sempty\n",
mx3_cam->active == buf ? " active" : "", sg_dma_address(&buf->sg),
vb->state, list_empty(&vb->queue) ? "" : "not ");
vb->state, list_empty(&vb->queue) ? "" : "not ");
spin_lock_irqsave(&mx3_cam->lock, flags);
if ((vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) &&
!list_empty(&vb->queue)) {
Expand Down Expand Up @@ -484,7 +486,7 @@ static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam,

clk_enable(mx3_cam->clk);
rate = clk_round_rate(mx3_cam->clk, mx3_cam->mclk);
dev_dbg(&icd->dev, "Set SENS_CONF to %x, rate %ld\n", conf, rate);
dev_dbg(icd->dev.parent, "Set SENS_CONF to %x, rate %ld\n", conf, rate);
if (rate)
clk_set_rate(mx3_cam->clk, rate);
}
Expand All @@ -502,7 +504,7 @@ static int mx3_camera_add_device(struct soc_camera_device *icd)

mx3_cam->icd = icd;

dev_info(&icd->dev, "MX3 Camera driver attached to camera %d\n",
dev_info(icd->dev.parent, "MX3 Camera driver attached to camera %d\n",
icd->devnum);

return 0;
Expand All @@ -526,7 +528,7 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd)

mx3_cam->icd = NULL;

dev_info(&icd->dev, "MX3 Camera driver detached from camera %d\n",
dev_info(icd->dev.parent, "MX3 Camera driver detached from camera %d\n",
icd->devnum);
}

Expand Down Expand Up @@ -603,7 +605,8 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd,
unsigned long bus_flags, camera_flags;
int ret = test_platform_param(mx3_cam, depth, &bus_flags);

dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n", depth, ret);
dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n",
depth, ret);

if (ret < 0)
return ret;
Expand All @@ -612,7 +615,8 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd,

ret = soc_camera_bus_param_compatible(camera_flags, bus_flags);
if (ret < 0)
dev_warn(&icd->dev, "Flags incompatible: camera %lx, host %lx\n",
dev_warn(icd->dev.parent,
"Flags incompatible: camera %lx, host %lx\n",
camera_flags, bus_flags);

return ret;
Expand Down Expand Up @@ -686,7 +690,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
dev_dbg(icd->dev.parent,
"Providing format %s using %s\n",
mx3_camera_formats[0].name,
icd->formats[idx].name);
}
Expand All @@ -698,7 +703,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth;
xlate++;
dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
dev_dbg(icd->dev.parent,
"Providing format %s using %s\n",
mx3_camera_formats[0].name,
icd->formats[idx].name);
}
Expand Down Expand Up @@ -821,7 +827,8 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,

xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
dev_warn(icd->dev.parent, "Format %x not found\n", pix->pixelformat);
dev_warn(icd->dev.parent, "Format %x not found\n",
pix->pixelformat);
return -EINVAL;
}

Expand Down Expand Up @@ -883,7 +890,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
if (field == V4L2_FIELD_ANY) {
pix->field = V4L2_FIELD_NONE;
} else if (field != V4L2_FIELD_NONE) {
dev_err(&icd->dev, "Field type %d unsupported.\n", field);
dev_err(icd->dev.parent, "Field type %d unsupported.\n", field);
return -EINVAL;
}

Expand Down Expand Up @@ -922,14 +929,15 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
u32 dw, sens_conf;
int ret = test_platform_param(mx3_cam, icd->buswidth, &bus_flags);
const struct soc_camera_format_xlate *xlate;
struct device *dev = icd->dev.parent;

xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
dev_warn(dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}

dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n",
dev_dbg(dev, "requested bus width %d bit: %d\n",
icd->buswidth, ret);

if (ret < 0)
Expand All @@ -938,10 +946,10 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
camera_flags = icd->ops->query_bus_param(icd);

common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
dev_dbg(icd->dev.parent, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n",
dev_dbg(dev, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n",
camera_flags, bus_flags, common_flags);
if (!common_flags) {
dev_dbg(icd->dev.parent, "no common flags");
dev_dbg(dev, "no common flags");
return -EINVAL;
}

Expand Down Expand Up @@ -995,7 +1003,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)

ret = icd->ops->set_bus_param(icd, common_flags);
if (ret < 0) {
dev_dbg(icd->dev.parent, "camera set_bus_param(%lx) returned %d\n",
dev_dbg(dev, "camera set_bus_param(%lx) returned %d\n",
common_flags, ret);
return ret;
}
Expand Down Expand Up @@ -1050,7 +1058,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)

csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF);

dev_dbg(icd->dev.parent, "Set SENS_CONF to %x\n", sens_conf | dw);
dev_dbg(dev, "Set SENS_CONF to %x\n", sens_conf | dw);

return 0;
}
Expand Down
Loading

0 comments on commit 0166b74

Please sign in to comment.