aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mx1_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-04-24 11:55:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:43 -0400
commiteff505fa1511b753b7cfb397a754b8ff4367cd55 (patch)
tree0e15a9094777bbebcfd1331b9e78f1aa6c6a5070 /drivers/media/video/mx1_camera.c
parenteb6c8558f7658b7f31ee022c7bea1d840eda33dc (diff)
V4L/DVB (11609): soc-camera: remove an extra device generation from struct soc_camera_host
Make camera devices direct children of host platform devices, move the inheritance management into the soc_camera.c core driver. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mx1_camera.c')
-rw-r--r--drivers/media/video/mx1_camera.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c
index 48dd984dadff..2d075205bdfe 100644
--- a/drivers/media/video/mx1_camera.c
+++ b/drivers/media/video/mx1_camera.c
@@ -106,7 +106,6 @@ struct mx1_camera_dev {
106 struct soc_camera_device *icd; 106 struct soc_camera_device *icd;
107 struct mx1_camera_pdata *pdata; 107 struct mx1_camera_pdata *pdata;
108 struct mx1_buffer *active; 108 struct mx1_buffer *active;
109 struct device *dev;
110 struct resource *res; 109 struct resource *res;
111 struct clk *clk; 110 struct clk *clk;
112 struct list_head capture; 111 struct list_head capture;
@@ -220,7 +219,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
220 int ret; 219 int ret;
221 220
222 if (unlikely(!pcdev->active)) { 221 if (unlikely(!pcdev->active)) {
223 dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); 222 dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
224 return -EFAULT; 223 return -EFAULT;
225 } 224 }
226 225
@@ -230,7 +229,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
230 vbuf->size, pcdev->res->start + 229 vbuf->size, pcdev->res->start +
231 CSIRXR, DMA_MODE_READ); 230 CSIRXR, DMA_MODE_READ);
232 if (unlikely(ret)) 231 if (unlikely(ret))
233 dev_err(pcdev->dev, "Failed to setup DMA sg list\n"); 232 dev_err(pcdev->soc_host.dev, "Failed to setup DMA sg list\n");
234 233
235 return ret; 234 return ret;
236} 235}
@@ -339,14 +338,14 @@ static void mx1_camera_dma_irq(int channel, void *data)
339 imx_dma_disable(channel); 338 imx_dma_disable(channel);
340 339
341 if (unlikely(!pcdev->active)) { 340 if (unlikely(!pcdev->active)) {
342 dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); 341 dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
343 goto out; 342 goto out;
344 } 343 }
345 344
346 vb = &pcdev->active->vb; 345 vb = &pcdev->active->vb;
347 buf = container_of(vb, struct mx1_buffer, vb); 346 buf = container_of(vb, struct mx1_buffer, vb);
348 WARN_ON(buf->inwork || list_empty(&vb->queue)); 347 WARN_ON(buf->inwork || list_empty(&vb->queue));
349 dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, 348 dev_dbg(pcdev->soc_host.dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
350 vb, vb->baddr, vb->bsize); 349 vb, vb->baddr, vb->bsize);
351 350
352 mx1_camera_wakeup(pcdev, vb, buf); 351 mx1_camera_wakeup(pcdev, vb, buf);
@@ -367,7 +366,7 @@ static void mx1_camera_init_videobuf(struct videobuf_queue *q,
367 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 366 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
368 struct mx1_camera_dev *pcdev = ici->priv; 367 struct mx1_camera_dev *pcdev = ici->priv;
369 368
370 videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, pcdev->dev, 369 videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, ici->dev,
371 &pcdev->lock, 370 &pcdev->lock,
372 V4L2_BUF_TYPE_VIDEO_CAPTURE, 371 V4L2_BUF_TYPE_VIDEO_CAPTURE,
373 V4L2_FIELD_NONE, 372 V4L2_FIELD_NONE,
@@ -386,7 +385,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
386 * they get a nice Oops */ 385 * they get a nice Oops */
387 div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1; 386 div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
388 387
389 dev_dbg(pcdev->dev, "System clock %lukHz, target freq %dkHz, " 388 dev_dbg(pcdev->soc_host.dev, "System clock %lukHz, target freq %dkHz, "
390 "divisor %lu\n", lcdclk / 1000, mclk / 1000, div); 389 "divisor %lu\n", lcdclk / 1000, mclk / 1000, div);
391 390
392 return div; 391 return div;
@@ -396,7 +395,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
396{ 395{
397 unsigned int csicr1 = CSICR1_EN; 396 unsigned int csicr1 = CSICR1_EN;
398 397
399 dev_dbg(pcdev->dev, "Activate device\n"); 398 dev_dbg(pcdev->soc_host.dev, "Activate device\n");
400 399
401 clk_enable(pcdev->clk); 400 clk_enable(pcdev->clk);
402 401
@@ -412,7 +411,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
412 411
413static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) 412static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
414{ 413{
415 dev_dbg(pcdev->dev, "Deactivate device\n"); 414 dev_dbg(pcdev->soc_host.dev, "Deactivate device\n");
416 415
417 /* Disable all CSI interface */ 416 /* Disable all CSI interface */
418 __raw_writel(0x00, pcdev->base + CSICR1); 417 __raw_writel(0x00, pcdev->base + CSICR1);
@@ -551,7 +550,7 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd,
551 550
552 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); 551 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
553 if (!xlate) { 552 if (!xlate) {
554 dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat); 553 dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
555 return -EINVAL; 554 return -EINVAL;
556 } 555 }
557 556
@@ -668,7 +667,6 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
668 goto exit_put_clk; 667 goto exit_put_clk;
669 } 668 }
670 669
671 platform_set_drvdata(pdev, pcdev);
672 pcdev->res = res; 670 pcdev->res = res;
673 pcdev->clk = clk; 671 pcdev->clk = clk;
674 672
@@ -702,16 +700,15 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
702 } 700 }
703 pcdev->irq = irq; 701 pcdev->irq = irq;
704 pcdev->base = base; 702 pcdev->base = base;
705 pcdev->dev = &pdev->dev;
706 703
707 /* request dma */ 704 /* request dma */
708 pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH); 705 pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH);
709 if (pcdev->dma_chan < 0) { 706 if (pcdev->dma_chan < 0) {
710 dev_err(pcdev->dev, "Can't request DMA for MX1 CSI\n"); 707 dev_err(&pdev->dev, "Can't request DMA for MX1 CSI\n");
711 err = -EBUSY; 708 err = -EBUSY;
712 goto exit_iounmap; 709 goto exit_iounmap;
713 } 710 }
714 dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chan); 711 dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chan);
715 712
716 imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL, 713 imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL,
717 pcdev); 714 pcdev);
@@ -724,7 +721,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
724 /* request irq */ 721 /* request irq */
725 err = claim_fiq(&fh); 722 err = claim_fiq(&fh);
726 if (err) { 723 if (err) {
727 dev_err(pcdev->dev, "Camera interrupt register failed \n"); 724 dev_err(&pdev->dev, "Camera interrupt register failed \n");
728 goto exit_free_dma; 725 goto exit_free_dma;
729 } 726 }
730 727
@@ -744,7 +741,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
744 pcdev->soc_host.drv_name = DRIVER_NAME; 741 pcdev->soc_host.drv_name = DRIVER_NAME;
745 pcdev->soc_host.ops = &mx1_soc_camera_host_ops; 742 pcdev->soc_host.ops = &mx1_soc_camera_host_ops;
746 pcdev->soc_host.priv = pcdev; 743 pcdev->soc_host.priv = pcdev;
747 pcdev->soc_host.dev.parent = &pdev->dev; 744 pcdev->soc_host.dev = &pdev->dev;
748 pcdev->soc_host.nr = pdev->id; 745 pcdev->soc_host.nr = pdev->id;
749 err = soc_camera_host_register(&pcdev->soc_host); 746 err = soc_camera_host_register(&pcdev->soc_host);
750 if (err) 747 if (err)
@@ -774,7 +771,9 @@ exit:
774 771
775static int __exit mx1_camera_remove(struct platform_device *pdev) 772static int __exit mx1_camera_remove(struct platform_device *pdev)
776{ 773{
777 struct mx1_camera_dev *pcdev = platform_get_drvdata(pdev); 774 struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
775 struct mx1_camera_dev *pcdev = container_of(soc_host,
776 struct mx1_camera_dev, soc_host);
778 struct resource *res; 777 struct resource *res;
779 778
780 imx_dma_free(pcdev->dma_chan); 779 imx_dma_free(pcdev->dma_chan);
@@ -784,7 +783,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev)
784 783
785 clk_put(pcdev->clk); 784 clk_put(pcdev->clk);
786 785
787 soc_camera_host_unregister(&pcdev->soc_host); 786 soc_camera_host_unregister(soc_host);
788 787
789 iounmap(pcdev->base); 788 iounmap(pcdev->base);
790 789