diff options
Diffstat (limited to 'drivers/media/video/pxa_camera.c')
-rw-r--r-- | drivers/media/video/pxa_camera.c | 107 |
1 files changed, 49 insertions, 58 deletions
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index 8b9b44d86837..bdc0d85c461b 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -270,7 +270,7 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf) | |||
270 | 270 | ||
271 | for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) { | 271 | for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) { |
272 | if (buf->dmas[i].sg_cpu) | 272 | if (buf->dmas[i].sg_cpu) |
273 | dma_free_coherent(ici->dev, buf->dmas[i].sg_size, | 273 | dma_free_coherent(ici->v4l2_dev.dev, buf->dmas[i].sg_size, |
274 | buf->dmas[i].sg_cpu, | 274 | buf->dmas[i].sg_cpu, |
275 | buf->dmas[i].sg_dma); | 275 | buf->dmas[i].sg_dma); |
276 | buf->dmas[i].sg_cpu = NULL; | 276 | buf->dmas[i].sg_cpu = NULL; |
@@ -325,19 +325,20 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | |||
325 | struct scatterlist **sg_first, int *sg_first_ofs) | 325 | struct scatterlist **sg_first, int *sg_first_ofs) |
326 | { | 326 | { |
327 | struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; | 327 | struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; |
328 | struct device *dev = pcdev->soc_host.v4l2_dev.dev; | ||
328 | struct scatterlist *sg; | 329 | struct scatterlist *sg; |
329 | int i, offset, sglen; | 330 | int i, offset, sglen; |
330 | int dma_len = 0, xfer_len = 0; | 331 | int dma_len = 0, xfer_len = 0; |
331 | 332 | ||
332 | if (pxa_dma->sg_cpu) | 333 | if (pxa_dma->sg_cpu) |
333 | dma_free_coherent(pcdev->soc_host.dev, pxa_dma->sg_size, | 334 | dma_free_coherent(dev, pxa_dma->sg_size, |
334 | pxa_dma->sg_cpu, pxa_dma->sg_dma); | 335 | pxa_dma->sg_cpu, pxa_dma->sg_dma); |
335 | 336 | ||
336 | sglen = calculate_dma_sglen(*sg_first, dma->sglen, | 337 | sglen = calculate_dma_sglen(*sg_first, dma->sglen, |
337 | *sg_first_ofs, size); | 338 | *sg_first_ofs, size); |
338 | 339 | ||
339 | pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc); | 340 | pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc); |
340 | pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->soc_host.dev, pxa_dma->sg_size, | 341 | pxa_dma->sg_cpu = dma_alloc_coherent(dev, pxa_dma->sg_size, |
341 | &pxa_dma->sg_dma, GFP_KERNEL); | 342 | &pxa_dma->sg_dma, GFP_KERNEL); |
342 | if (!pxa_dma->sg_cpu) | 343 | if (!pxa_dma->sg_cpu) |
343 | return -ENOMEM; | 344 | return -ENOMEM; |
@@ -345,7 +346,7 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | |||
345 | pxa_dma->sglen = sglen; | 346 | pxa_dma->sglen = sglen; |
346 | offset = *sg_first_ofs; | 347 | offset = *sg_first_ofs; |
347 | 348 | ||
348 | dev_dbg(pcdev->soc_host.dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n", | 349 | dev_dbg(dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n", |
349 | *sg_first, sglen, *sg_first_ofs, pxa_dma->sg_dma); | 350 | *sg_first, sglen, *sg_first_ofs, pxa_dma->sg_dma); |
350 | 351 | ||
351 | 352 | ||
@@ -368,7 +369,7 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | |||
368 | pxa_dma->sg_cpu[i].ddadr = | 369 | pxa_dma->sg_cpu[i].ddadr = |
369 | pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc); | 370 | pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc); |
370 | 371 | ||
371 | dev_vdbg(pcdev->soc_host.dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n", | 372 | dev_vdbg(dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n", |
372 | pxa_dma->sg_dma + i * sizeof(struct pxa_dma_desc), | 373 | pxa_dma->sg_dma + i * sizeof(struct pxa_dma_desc), |
373 | sg_dma_address(sg) + offset, xfer_len); | 374 | sg_dma_address(sg) + offset, xfer_len); |
374 | offset = 0; | 375 | offset = 0; |
@@ -418,11 +419,12 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
418 | struct soc_camera_device *icd = vq->priv_data; | 419 | struct soc_camera_device *icd = vq->priv_data; |
419 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 420 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
420 | struct pxa_camera_dev *pcdev = ici->priv; | 421 | struct pxa_camera_dev *pcdev = ici->priv; |
422 | struct device *dev = pcdev->soc_host.v4l2_dev.dev; | ||
421 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | 423 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); |
422 | int ret; | 424 | int ret; |
423 | int size_y, size_u = 0, size_v = 0; | 425 | int size_y, size_u = 0, size_v = 0; |
424 | 426 | ||
425 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | 427 | dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, |
426 | vb, vb->baddr, vb->bsize); | 428 | vb, vb->baddr, vb->bsize); |
427 | 429 | ||
428 | /* Added list head initialization on alloc */ | 430 | /* Added list head initialization on alloc */ |
@@ -480,8 +482,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
480 | ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0, size_y, | 482 | ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0, size_y, |
481 | &sg, &next_ofs); | 483 | &sg, &next_ofs); |
482 | if (ret) { | 484 | if (ret) { |
483 | dev_err(pcdev->soc_host.dev, | 485 | dev_err(dev, "DMA initialization for Y/RGB failed\n"); |
484 | "DMA initialization for Y/RGB failed\n"); | ||
485 | goto fail; | 486 | goto fail; |
486 | } | 487 | } |
487 | 488 | ||
@@ -490,8 +491,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
490 | ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1, | 491 | ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1, |
491 | size_u, &sg, &next_ofs); | 492 | size_u, &sg, &next_ofs); |
492 | if (ret) { | 493 | if (ret) { |
493 | dev_err(pcdev->soc_host.dev, | 494 | dev_err(dev, "DMA initialization for U failed\n"); |
494 | "DMA initialization for U failed\n"); | ||
495 | goto fail_u; | 495 | goto fail_u; |
496 | } | 496 | } |
497 | 497 | ||
@@ -500,8 +500,7 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
500 | ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2, | 500 | ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2, |
501 | size_v, &sg, &next_ofs); | 501 | size_v, &sg, &next_ofs); |
502 | if (ret) { | 502 | if (ret) { |
503 | dev_err(pcdev->soc_host.dev, | 503 | dev_err(dev, "DMA initialization for V failed\n"); |
504 | "DMA initialization for V failed\n"); | ||
505 | goto fail_v; | 504 | goto fail_v; |
506 | } | 505 | } |
507 | 506 | ||
@@ -514,10 +513,10 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
514 | return 0; | 513 | return 0; |
515 | 514 | ||
516 | fail_v: | 515 | fail_v: |
517 | dma_free_coherent(pcdev->soc_host.dev, buf->dmas[1].sg_size, | 516 | dma_free_coherent(dev, buf->dmas[1].sg_size, |
518 | buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma); | 517 | buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma); |
519 | fail_u: | 518 | fail_u: |
520 | dma_free_coherent(pcdev->soc_host.dev, buf->dmas[0].sg_size, | 519 | dma_free_coherent(dev, buf->dmas[0].sg_size, |
521 | buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma); | 520 | buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma); |
522 | fail: | 521 | fail: |
523 | free_buffer(vq, buf); | 522 | free_buffer(vq, buf); |
@@ -541,7 +540,7 @@ static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev) | |||
541 | active = pcdev->active; | 540 | active = pcdev->active; |
542 | 541 | ||
543 | for (i = 0; i < pcdev->channels; i++) { | 542 | for (i = 0; i < pcdev->channels; i++) { |
544 | dev_dbg(pcdev->soc_host.dev, "%s (channel=%d) ddadr=%08x\n", __func__, | 543 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s (channel=%d) ddadr=%08x\n", __func__, |
545 | i, active->dmas[i].sg_dma); | 544 | i, active->dmas[i].sg_dma); |
546 | DDADR(pcdev->dma_chans[i]) = active->dmas[i].sg_dma; | 545 | DDADR(pcdev->dma_chans[i]) = active->dmas[i].sg_dma; |
547 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | 546 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; |
@@ -553,7 +552,7 @@ static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev) | |||
553 | int i; | 552 | int i; |
554 | 553 | ||
555 | for (i = 0; i < pcdev->channels; i++) { | 554 | for (i = 0; i < pcdev->channels; i++) { |
556 | dev_dbg(pcdev->soc_host.dev, "%s (channel=%d)\n", __func__, i); | 555 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s (channel=%d)\n", __func__, i); |
557 | DCSR(pcdev->dma_chans[i]) = 0; | 556 | DCSR(pcdev->dma_chans[i]) = 0; |
558 | } | 557 | } |
559 | } | 558 | } |
@@ -589,7 +588,7 @@ static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev) | |||
589 | { | 588 | { |
590 | unsigned long cicr0, cifr; | 589 | unsigned long cicr0, cifr; |
591 | 590 | ||
592 | dev_dbg(pcdev->soc_host.dev, "%s\n", __func__); | 591 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__); |
593 | /* Reset the FIFOs */ | 592 | /* Reset the FIFOs */ |
594 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; | 593 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; |
595 | __raw_writel(cifr, pcdev->base + CIFR); | 594 | __raw_writel(cifr, pcdev->base + CIFR); |
@@ -609,7 +608,7 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev) | |||
609 | __raw_writel(cicr0, pcdev->base + CICR0); | 608 | __raw_writel(cicr0, pcdev->base + CICR0); |
610 | 609 | ||
611 | pcdev->active = NULL; | 610 | pcdev->active = NULL; |
612 | dev_dbg(pcdev->soc_host.dev, "%s\n", __func__); | 611 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__); |
613 | } | 612 | } |
614 | 613 | ||
615 | /* Called under spinlock_irqsave(&pcdev->lock, ...) */ | 614 | /* Called under spinlock_irqsave(&pcdev->lock, ...) */ |
@@ -674,7 +673,8 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, | |||
674 | do_gettimeofday(&vb->ts); | 673 | do_gettimeofday(&vb->ts); |
675 | vb->field_count++; | 674 | vb->field_count++; |
676 | wake_up(&vb->done); | 675 | wake_up(&vb->done); |
677 | dev_dbg(pcdev->soc_host.dev, "%s dequeud buffer (vb=0x%p)\n", __func__, vb); | 676 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s dequeud buffer (vb=0x%p)\n", |
677 | __func__, vb); | ||
678 | 678 | ||
679 | if (list_empty(&pcdev->capture)) { | 679 | if (list_empty(&pcdev->capture)) { |
680 | pxa_camera_stop_capture(pcdev); | 680 | pxa_camera_stop_capture(pcdev); |
@@ -710,7 +710,8 @@ static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev) | |||
710 | for (i = 0; i < pcdev->channels; i++) | 710 | for (i = 0; i < pcdev->channels; i++) |
711 | if (DDADR(pcdev->dma_chans[i]) != DDADR_STOP) | 711 | if (DDADR(pcdev->dma_chans[i]) != DDADR_STOP) |
712 | is_dma_stopped = 0; | 712 | is_dma_stopped = 0; |
713 | dev_dbg(pcdev->soc_host.dev, "%s : top queued buffer=%p, dma_stopped=%d\n", | 713 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, |
714 | "%s : top queued buffer=%p, dma_stopped=%d\n", | ||
714 | __func__, pcdev->active, is_dma_stopped); | 715 | __func__, pcdev->active, is_dma_stopped); |
715 | if (pcdev->active && is_dma_stopped) | 716 | if (pcdev->active && is_dma_stopped) |
716 | pxa_camera_start_capture(pcdev); | 717 | pxa_camera_start_capture(pcdev); |
@@ -719,6 +720,7 @@ static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev) | |||
719 | static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | 720 | static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, |
720 | enum pxa_camera_active_dma act_dma) | 721 | enum pxa_camera_active_dma act_dma) |
721 | { | 722 | { |
723 | struct device *dev = pcdev->soc_host.v4l2_dev.dev; | ||
722 | struct pxa_buffer *buf; | 724 | struct pxa_buffer *buf; |
723 | unsigned long flags; | 725 | unsigned long flags; |
724 | u32 status, camera_status, overrun; | 726 | u32 status, camera_status, overrun; |
@@ -735,13 +737,13 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | |||
735 | overrun |= CISR_IFO_1 | CISR_IFO_2; | 737 | overrun |= CISR_IFO_1 | CISR_IFO_2; |
736 | 738 | ||
737 | if (status & DCSR_BUSERR) { | 739 | if (status & DCSR_BUSERR) { |
738 | dev_err(pcdev->soc_host.dev, "DMA Bus Error IRQ!\n"); | 740 | dev_err(dev, "DMA Bus Error IRQ!\n"); |
739 | goto out; | 741 | goto out; |
740 | } | 742 | } |
741 | 743 | ||
742 | if (!(status & (DCSR_ENDINTR | DCSR_STARTINTR))) { | 744 | if (!(status & (DCSR_ENDINTR | DCSR_STARTINTR))) { |
743 | dev_err(pcdev->soc_host.dev, "Unknown DMA IRQ source, " | 745 | dev_err(dev, "Unknown DMA IRQ source, status: 0x%08x\n", |
744 | "status: 0x%08x\n", status); | 746 | status); |
745 | goto out; | 747 | goto out; |
746 | } | 748 | } |
747 | 749 | ||
@@ -764,7 +766,7 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | |||
764 | buf = container_of(vb, struct pxa_buffer, vb); | 766 | buf = container_of(vb, struct pxa_buffer, vb); |
765 | WARN_ON(buf->inwork || list_empty(&vb->queue)); | 767 | WARN_ON(buf->inwork || list_empty(&vb->queue)); |
766 | 768 | ||
767 | dev_dbg(pcdev->soc_host.dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n", | 769 | dev_dbg(dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n", |
768 | __func__, channel, status & DCSR_STARTINTR ? "SOF " : "", | 770 | __func__, channel, status & DCSR_STARTINTR ? "SOF " : "", |
769 | status & DCSR_ENDINTR ? "EOF " : "", vb, DDADR(channel)); | 771 | status & DCSR_ENDINTR ? "EOF " : "", vb, DDADR(channel)); |
770 | 772 | ||
@@ -775,7 +777,7 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | |||
775 | */ | 777 | */ |
776 | if (camera_status & overrun && | 778 | if (camera_status & overrun && |
777 | !list_is_last(pcdev->capture.next, &pcdev->capture)) { | 779 | !list_is_last(pcdev->capture.next, &pcdev->capture)) { |
778 | dev_dbg(pcdev->soc_host.dev, "FIFO overrun! CISR: %x\n", | 780 | dev_dbg(dev, "FIFO overrun! CISR: %x\n", |
779 | camera_status); | 781 | camera_status); |
780 | pxa_camera_stop_capture(pcdev); | 782 | pxa_camera_stop_capture(pcdev); |
781 | pxa_camera_start_capture(pcdev); | 783 | pxa_camera_start_capture(pcdev); |
@@ -834,6 +836,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev, | |||
834 | struct pxa_camera_dev *pcdev) | 836 | struct pxa_camera_dev *pcdev) |
835 | { | 837 | { |
836 | unsigned long mclk = pcdev->mclk; | 838 | unsigned long mclk = pcdev->mclk; |
839 | struct device *dev = pcdev->soc_host.v4l2_dev.dev; | ||
837 | u32 div; | 840 | u32 div; |
838 | unsigned long lcdclk; | 841 | unsigned long lcdclk; |
839 | 842 | ||
@@ -843,7 +846,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev, | |||
843 | /* mclk <= ciclk / 4 (27.4.2) */ | 846 | /* mclk <= ciclk / 4 (27.4.2) */ |
844 | if (mclk > lcdclk / 4) { | 847 | if (mclk > lcdclk / 4) { |
845 | mclk = lcdclk / 4; | 848 | mclk = lcdclk / 4; |
846 | dev_warn(&pdev->dev, "Limiting master clock to %lu\n", mclk); | 849 | dev_warn(dev, "Limiting master clock to %lu\n", mclk); |
847 | } | 850 | } |
848 | 851 | ||
849 | /* We verify mclk != 0, so if anyone breaks it, here comes their Oops */ | 852 | /* We verify mclk != 0, so if anyone breaks it, here comes their Oops */ |
@@ -853,7 +856,7 @@ static u32 mclk_get_divisor(struct platform_device *pdev, | |||
853 | if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) | 856 | if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) |
854 | pcdev->mclk = lcdclk / (2 * (div + 1)); | 857 | pcdev->mclk = lcdclk / (2 * (div + 1)); |
855 | 858 | ||
856 | dev_dbg(&pdev->dev, "LCD clock %luHz, target freq %luHz, divisor %u\n", | 859 | dev_dbg(dev, "LCD clock %luHz, target freq %luHz, divisor %u\n", |
857 | lcdclk, mclk, div); | 860 | lcdclk, mclk, div); |
858 | 861 | ||
859 | return div; | 862 | return div; |
@@ -871,14 +874,15 @@ static void recalculate_fifo_timeout(struct pxa_camera_dev *pcdev, | |||
871 | static void pxa_camera_activate(struct pxa_camera_dev *pcdev) | 874 | static void pxa_camera_activate(struct pxa_camera_dev *pcdev) |
872 | { | 875 | { |
873 | struct pxacamera_platform_data *pdata = pcdev->pdata; | 876 | struct pxacamera_platform_data *pdata = pcdev->pdata; |
877 | struct device *dev = pcdev->soc_host.v4l2_dev.dev; | ||
874 | u32 cicr4 = 0; | 878 | u32 cicr4 = 0; |
875 | 879 | ||
876 | dev_dbg(pcdev->soc_host.dev, "Registered platform device at %p data %p\n", | 880 | dev_dbg(dev, "Registered platform device at %p data %p\n", |
877 | pcdev, pdata); | 881 | pcdev, pdata); |
878 | 882 | ||
879 | if (pdata && pdata->init) { | 883 | if (pdata && pdata->init) { |
880 | dev_dbg(pcdev->soc_host.dev, "%s: Init gpios\n", __func__); | 884 | dev_dbg(dev, "%s: Init gpios\n", __func__); |
881 | pdata->init(pcdev->soc_host.dev); | 885 | pdata->init(dev); |
882 | } | 886 | } |
883 | 887 | ||
884 | /* disable all interrupts */ | 888 | /* disable all interrupts */ |
@@ -920,7 +924,7 @@ static irqreturn_t pxa_camera_irq(int irq, void *data) | |||
920 | struct videobuf_buffer *vb; | 924 | struct videobuf_buffer *vb; |
921 | 925 | ||
922 | status = __raw_readl(pcdev->base + CISR); | 926 | status = __raw_readl(pcdev->base + CISR); |
923 | dev_dbg(pcdev->soc_host.dev, "Camera interrupt status 0x%lx\n", status); | 927 | dev_dbg(pcdev->soc_host.v4l2_dev.dev, "Camera interrupt status 0x%lx\n", status); |
924 | 928 | ||
925 | if (!status) | 929 | if (!status) |
926 | return IRQ_NONE; | 930 | return IRQ_NONE; |
@@ -952,17 +956,11 @@ static int pxa_camera_add_device(struct soc_camera_device *icd) | |||
952 | { | 956 | { |
953 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 957 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
954 | struct pxa_camera_dev *pcdev = ici->priv; | 958 | struct pxa_camera_dev *pcdev = ici->priv; |
955 | int ret; | ||
956 | 959 | ||
957 | if (pcdev->icd) { | 960 | if (pcdev->icd) |
958 | ret = -EBUSY; | 961 | return -EBUSY; |
959 | goto ebusy; | ||
960 | } | ||
961 | 962 | ||
962 | pxa_camera_activate(pcdev); | 963 | pxa_camera_activate(pcdev); |
963 | ret = icd->ops->init(icd); | ||
964 | if (ret < 0) | ||
965 | goto einit; | ||
966 | 964 | ||
967 | pcdev->icd = icd; | 965 | pcdev->icd = icd; |
968 | 966 | ||
@@ -970,11 +968,6 @@ static int pxa_camera_add_device(struct soc_camera_device *icd) | |||
970 | icd->devnum); | 968 | icd->devnum); |
971 | 969 | ||
972 | return 0; | 970 | return 0; |
973 | |||
974 | einit: | ||
975 | pxa_camera_deactivate(pcdev); | ||
976 | ebusy: | ||
977 | return ret; | ||
978 | } | 971 | } |
979 | 972 | ||
980 | /* Called with .video_lock held */ | 973 | /* Called with .video_lock held */ |
@@ -996,8 +989,6 @@ static void pxa_camera_remove_device(struct soc_camera_device *icd) | |||
996 | DCSR(pcdev->dma_chans[1]) = 0; | 989 | DCSR(pcdev->dma_chans[1]) = 0; |
997 | DCSR(pcdev->dma_chans[2]) = 0; | 990 | DCSR(pcdev->dma_chans[2]) = 0; |
998 | 991 | ||
999 | icd->ops->release(icd); | ||
1000 | |||
1001 | pxa_camera_deactivate(pcdev); | 992 | pxa_camera_deactivate(pcdev); |
1002 | 993 | ||
1003 | pcdev->icd = NULL; | 994 | pcdev->icd = NULL; |
@@ -1253,7 +1244,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx, | |||
1253 | xlate->cam_fmt = icd->formats + idx; | 1244 | xlate->cam_fmt = icd->formats + idx; |
1254 | xlate->buswidth = buswidth; | 1245 | xlate->buswidth = buswidth; |
1255 | xlate++; | 1246 | xlate++; |
1256 | dev_dbg(ici->dev, "Providing format %s using %s\n", | 1247 | dev_dbg(ici->v4l2_dev.dev, "Providing format %s using %s\n", |
1257 | pxa_camera_formats[0].name, | 1248 | pxa_camera_formats[0].name, |
1258 | icd->formats[idx].name); | 1249 | icd->formats[idx].name); |
1259 | } | 1250 | } |
@@ -1268,7 +1259,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx, | |||
1268 | xlate->cam_fmt = icd->formats + idx; | 1259 | xlate->cam_fmt = icd->formats + idx; |
1269 | xlate->buswidth = buswidth; | 1260 | xlate->buswidth = buswidth; |
1270 | xlate++; | 1261 | xlate++; |
1271 | dev_dbg(ici->dev, "Providing format %s packed\n", | 1262 | dev_dbg(ici->v4l2_dev.dev, "Providing format %s packed\n", |
1272 | icd->formats[idx].name); | 1263 | icd->formats[idx].name); |
1273 | } | 1264 | } |
1274 | break; | 1265 | break; |
@@ -1280,7 +1271,7 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx, | |||
1280 | xlate->cam_fmt = icd->formats + idx; | 1271 | xlate->cam_fmt = icd->formats + idx; |
1281 | xlate->buswidth = icd->formats[idx].depth; | 1272 | xlate->buswidth = icd->formats[idx].depth; |
1282 | xlate++; | 1273 | xlate++; |
1283 | dev_dbg(ici->dev, | 1274 | dev_dbg(ici->v4l2_dev.dev, |
1284 | "Providing format %s in pass-through mode\n", | 1275 | "Providing format %s in pass-through mode\n", |
1285 | icd->formats[idx].name); | 1276 | icd->formats[idx].name); |
1286 | } | 1277 | } |
@@ -1309,11 +1300,11 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd, | |||
1309 | icd->sense = NULL; | 1300 | icd->sense = NULL; |
1310 | 1301 | ||
1311 | if (ret < 0) { | 1302 | if (ret < 0) { |
1312 | dev_warn(ici->dev, "Failed to crop to %ux%u@%u:%u\n", | 1303 | dev_warn(ici->v4l2_dev.dev, "Failed to crop to %ux%u@%u:%u\n", |
1313 | rect->width, rect->height, rect->left, rect->top); | 1304 | rect->width, rect->height, rect->left, rect->top); |
1314 | } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { | 1305 | } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { |
1315 | if (sense.pixel_clock > sense.pixel_clock_max) { | 1306 | if (sense.pixel_clock > sense.pixel_clock_max) { |
1316 | dev_err(ici->dev, | 1307 | dev_err(ici->v4l2_dev.dev, |
1317 | "pixel clock %lu set by the camera too high!", | 1308 | "pixel clock %lu set by the camera too high!", |
1318 | sense.pixel_clock); | 1309 | sense.pixel_clock); |
1319 | return -EIO; | 1310 | return -EIO; |
@@ -1341,7 +1332,7 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, | |||
1341 | 1332 | ||
1342 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); | 1333 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); |
1343 | if (!xlate) { | 1334 | if (!xlate) { |
1344 | dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat); | 1335 | dev_warn(ici->v4l2_dev.dev, "Format %x not found\n", pix->pixelformat); |
1345 | return -EINVAL; | 1336 | return -EINVAL; |
1346 | } | 1337 | } |
1347 | 1338 | ||
@@ -1352,16 +1343,16 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, | |||
1352 | icd->sense = &sense; | 1343 | icd->sense = &sense; |
1353 | 1344 | ||
1354 | cam_f.fmt.pix.pixelformat = cam_fmt->fourcc; | 1345 | cam_f.fmt.pix.pixelformat = cam_fmt->fourcc; |
1355 | ret = icd->ops->set_fmt(icd, &cam_f); | 1346 | ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, s_fmt, f); |
1356 | 1347 | ||
1357 | icd->sense = NULL; | 1348 | icd->sense = NULL; |
1358 | 1349 | ||
1359 | if (ret < 0) { | 1350 | if (ret < 0) { |
1360 | dev_warn(ici->dev, "Failed to configure for format %x\n", | 1351 | dev_warn(ici->v4l2_dev.dev, "Failed to configure for format %x\n", |
1361 | pix->pixelformat); | 1352 | pix->pixelformat); |
1362 | } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { | 1353 | } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { |
1363 | if (sense.pixel_clock > sense.pixel_clock_max) { | 1354 | if (sense.pixel_clock > sense.pixel_clock_max) { |
1364 | dev_err(ici->dev, | 1355 | dev_err(ici->v4l2_dev.dev, |
1365 | "pixel clock %lu set by the camera too high!", | 1356 | "pixel clock %lu set by the camera too high!", |
1366 | sense.pixel_clock); | 1357 | sense.pixel_clock); |
1367 | return -EIO; | 1358 | return -EIO; |
@@ -1389,7 +1380,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd, | |||
1389 | 1380 | ||
1390 | xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); | 1381 | xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); |
1391 | if (!xlate) { | 1382 | if (!xlate) { |
1392 | dev_warn(ici->dev, "Format %x not found\n", pixfmt); | 1383 | dev_warn(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt); |
1393 | return -EINVAL; | 1384 | return -EINVAL; |
1394 | } | 1385 | } |
1395 | 1386 | ||
@@ -1410,7 +1401,7 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd, | |||
1410 | /* camera has to see its format, but the user the original one */ | 1401 | /* camera has to see its format, but the user the original one */ |
1411 | pix->pixelformat = xlate->cam_fmt->fourcc; | 1402 | pix->pixelformat = xlate->cam_fmt->fourcc; |
1412 | /* limit to sensor capabilities */ | 1403 | /* limit to sensor capabilities */ |
1413 | ret = icd->ops->try_fmt(icd, f); | 1404 | ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, try_fmt, f); |
1414 | pix->pixelformat = xlate->host_fmt->fourcc; | 1405 | pix->pixelformat = xlate->host_fmt->fourcc; |
1415 | 1406 | ||
1416 | field = pix->field; | 1407 | field = pix->field; |
@@ -1646,7 +1637,7 @@ static int __devinit pxa_camera_probe(struct platform_device *pdev) | |||
1646 | pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME; | 1637 | pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME; |
1647 | pcdev->soc_host.ops = &pxa_soc_camera_host_ops; | 1638 | pcdev->soc_host.ops = &pxa_soc_camera_host_ops; |
1648 | pcdev->soc_host.priv = pcdev; | 1639 | pcdev->soc_host.priv = pcdev; |
1649 | pcdev->soc_host.dev = &pdev->dev; | 1640 | pcdev->soc_host.v4l2_dev.dev = &pdev->dev; |
1650 | pcdev->soc_host.nr = pdev->id; | 1641 | pcdev->soc_host.nr = pdev->id; |
1651 | 1642 | ||
1652 | err = soc_camera_host_register(&pcdev->soc_host); | 1643 | err = soc_camera_host_register(&pcdev->soc_host); |