Lines Matching refs:pcdev
773 static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev) in pcdev_to_dev() argument
775 return pcdev->v4l2_dev.dev; in pcdev_to_dev()
783 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
788 struct pxa_camera_dev *pcdev = data; in pxa_camera_dma_irq_y() local
790 pxa_camera_dma_irq(pcdev, DMA_Y); in pxa_camera_dma_irq_y()
795 struct pxa_camera_dev *pcdev = data; in pxa_camera_dma_irq_u() local
797 pxa_camera_dma_irq(pcdev, DMA_U); in pxa_camera_dma_irq_u()
802 struct pxa_camera_dev *pcdev = data; in pxa_camera_dma_irq_v() local
804 pxa_camera_dma_irq(pcdev, DMA_V); in pxa_camera_dma_irq_v()
819 static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, in pxa_init_dma_channel() argument
823 struct dma_chan *dma_chan = pcdev->dma_chans[channel]; in pxa_init_dma_channel()
829 dev_err(pcdev_to_dev(pcdev), in pxa_init_dma_channel()
834 tx->callback_param = pcdev; in pxa_init_dma_channel()
850 dev_dbg(pcdev_to_dev(pcdev), in pxa_init_dma_channel()
857 static void pxa_video_buf_set_actdma(struct pxa_camera_dev *pcdev, in pxa_video_buf_set_actdma() argument
872 static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev) in pxa_dma_start_channels() argument
876 for (i = 0; i < pcdev->channels; i++) { in pxa_dma_start_channels()
877 dev_dbg(pcdev_to_dev(pcdev), in pxa_dma_start_channels()
879 dma_async_issue_pending(pcdev->dma_chans[i]); in pxa_dma_start_channels()
883 static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev) in pxa_dma_stop_channels() argument
887 for (i = 0; i < pcdev->channels; i++) { in pxa_dma_stop_channels()
888 dev_dbg(pcdev_to_dev(pcdev), in pxa_dma_stop_channels()
890 dmaengine_terminate_all(pcdev->dma_chans[i]); in pxa_dma_stop_channels()
894 static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev, in pxa_dma_add_tail_buf() argument
899 for (i = 0; i < pcdev->channels; i++) { in pxa_dma_add_tail_buf()
901 dev_dbg(pcdev_to_dev(pcdev), in pxa_dma_add_tail_buf()
915 static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev) in pxa_camera_start_capture() argument
919 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__); in pxa_camera_start_capture()
920 __raw_writel(__raw_readl(pcdev->base + CISR), pcdev->base + CISR); in pxa_camera_start_capture()
922 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB; in pxa_camera_start_capture()
924 __raw_writel(cicr0, pcdev->base + CICR0); in pxa_camera_start_capture()
927 static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev) in pxa_camera_stop_capture() argument
931 pxa_dma_stop_channels(pcdev); in pxa_camera_stop_capture()
933 cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB; in pxa_camera_stop_capture()
934 __raw_writel(cicr0, pcdev->base + CICR0); in pxa_camera_stop_capture()
936 pcdev->active = NULL; in pxa_camera_stop_capture()
937 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__); in pxa_camera_stop_capture()
940 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, in pxa_camera_wakeup() argument
950 vbuf->sequence = pcdev->buf_sequence++; in pxa_camera_wakeup()
953 dev_dbg(pcdev_to_dev(pcdev), "%s dequeued buffer (buf=0x%p)\n", in pxa_camera_wakeup()
956 if (list_empty(&pcdev->capture)) { in pxa_camera_wakeup()
957 pxa_camera_stop_capture(pcdev); in pxa_camera_wakeup()
961 pcdev->active = list_entry(pcdev->capture.next, in pxa_camera_wakeup()
983 static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev, in pxa_camera_check_link_miss() argument
989 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_check_link_miss()
991 __func__, pcdev->active, is_dma_stopped); in pxa_camera_check_link_miss()
993 if (pcdev->active && is_dma_stopped) in pxa_camera_check_link_miss()
994 pxa_camera_start_capture(pcdev); in pxa_camera_check_link_miss()
997 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev, in pxa_camera_dma_irq() argument
1007 spin_lock_irqsave(&pcdev->lock, flags); in pxa_camera_dma_irq()
1009 camera_status = __raw_readl(pcdev->base + CISR); in pxa_camera_dma_irq()
1010 dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n", in pxa_camera_dma_irq()
1013 if (pcdev->channels == 3) in pxa_camera_dma_irq()
1028 if (!pcdev->active) in pxa_camera_dma_irq()
1031 buf = pcdev->active; in pxa_camera_dma_irq()
1049 last_buf = list_entry(pcdev->capture.prev, in pxa_camera_dma_irq()
1051 last_status = dma_async_is_tx_complete(pcdev->dma_chans[chan], in pxa_camera_dma_irq()
1056 dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n", in pxa_camera_dma_irq()
1058 pxa_camera_stop_capture(pcdev); in pxa_camera_dma_irq()
1059 list_for_each_entry(buf, &pcdev->capture, queue) in pxa_camera_dma_irq()
1060 pxa_dma_add_tail_buf(pcdev, buf); in pxa_camera_dma_irq()
1061 pxa_camera_start_capture(pcdev); in pxa_camera_dma_irq()
1066 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE); in pxa_camera_dma_irq()
1067 pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan], in pxa_camera_dma_irq()
1072 spin_unlock_irqrestore(&pcdev->lock, flags); in pxa_camera_dma_irq()
1076 struct pxa_camera_dev *pcdev) in mclk_get_divisor() argument
1078 unsigned long mclk = pcdev->mclk; in mclk_get_divisor()
1082 lcdclk = clk_get_rate(pcdev->clk); in mclk_get_divisor()
1083 pcdev->ciclk = lcdclk; in mclk_get_divisor()
1096 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) in mclk_get_divisor()
1097 pcdev->mclk = lcdclk / (2 * (div + 1)); in mclk_get_divisor()
1105 static void recalculate_fifo_timeout(struct pxa_camera_dev *pcdev, in recalculate_fifo_timeout() argument
1109 u32 ciclk_per_pixel = pcdev->ciclk / pclk + 1; in recalculate_fifo_timeout()
1111 __raw_writel(ciclk_per_pixel, pcdev->base + CITOR); in recalculate_fifo_timeout()
1114 static void pxa_camera_activate(struct pxa_camera_dev *pcdev) in pxa_camera_activate() argument
1119 __raw_writel(0x3ff, pcdev->base + CICR0); in pxa_camera_activate()
1121 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN) in pxa_camera_activate()
1123 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) in pxa_camera_activate()
1125 if (pcdev->platform_flags & PXA_CAMERA_PCP) in pxa_camera_activate()
1127 if (pcdev->platform_flags & PXA_CAMERA_HSP) in pxa_camera_activate()
1129 if (pcdev->platform_flags & PXA_CAMERA_VSP) in pxa_camera_activate()
1132 __raw_writel(pcdev->mclk_divisor | cicr4, pcdev->base + CICR4); in pxa_camera_activate()
1134 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) in pxa_camera_activate()
1136 recalculate_fifo_timeout(pcdev, pcdev->mclk); in pxa_camera_activate()
1139 recalculate_fifo_timeout(pcdev, 13000000); in pxa_camera_activate()
1141 clk_prepare_enable(pcdev->clk); in pxa_camera_activate()
1144 static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev) in pxa_camera_deactivate() argument
1146 clk_disable_unprepare(pcdev->clk); in pxa_camera_deactivate()
1151 struct pxa_camera_dev *pcdev = from_tasklet(pcdev, t, task_eof); in pxa_camera_eof() local
1155 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_eof()
1157 __raw_readl(pcdev->base + CISR)); in pxa_camera_eof()
1160 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; in pxa_camera_eof()
1161 __raw_writel(cifr, pcdev->base + CIFR); in pxa_camera_eof()
1163 pcdev->active = list_first_entry(&pcdev->capture, in pxa_camera_eof()
1165 buf = pcdev->active; in pxa_camera_eof()
1166 pxa_video_buf_set_actdma(pcdev, buf); in pxa_camera_eof()
1168 pxa_dma_start_channels(pcdev); in pxa_camera_eof()
1173 struct pxa_camera_dev *pcdev = data; in pxa_camera_irq() local
1176 status = __raw_readl(pcdev->base + CISR); in pxa_camera_irq()
1177 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_irq()
1183 __raw_writel(status, pcdev->base + CISR); in pxa_camera_irq()
1186 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM; in pxa_camera_irq()
1187 __raw_writel(cicr0, pcdev->base + CICR0); in pxa_camera_irq()
1188 tasklet_schedule(&pcdev->task_eof); in pxa_camera_irq()
1194 static void pxa_camera_setup_cicr(struct pxa_camera_dev *pcdev, in pxa_camera_setup_cicr() argument
1199 int ret = sensor_call(pcdev, sensor, g_skip_top_lines, &y_skip_top); in pxa_camera_setup_cicr()
1208 switch (pcdev->current_fmt->host_fmt->bits_per_sample) { in pxa_camera_setup_cicr()
1227 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN) in pxa_camera_setup_cicr()
1229 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) in pxa_camera_setup_cicr()
1238 cicr0 = __raw_readl(pcdev->base + CICR0); in pxa_camera_setup_cicr()
1240 __raw_writel(cicr0 & ~CICR0_ENB, pcdev->base + CICR0); in pxa_camera_setup_cicr()
1242 cicr1 = CICR1_PPL_VAL(pcdev->current_pix.width - 1) | bpp | dw; in pxa_camera_setup_cicr()
1246 pcdev->channels = 3; in pxa_camera_setup_cicr()
1272 cicr3 = CICR3_LPF_VAL(pcdev->current_pix.height - 1) | in pxa_camera_setup_cicr()
1274 cicr4 |= pcdev->mclk_divisor; in pxa_camera_setup_cicr()
1276 __raw_writel(cicr1, pcdev->base + CICR1); in pxa_camera_setup_cicr()
1277 __raw_writel(cicr2, pcdev->base + CICR2); in pxa_camera_setup_cicr()
1278 __raw_writel(cicr3, pcdev->base + CICR3); in pxa_camera_setup_cicr()
1279 __raw_writel(cicr4, pcdev->base + CICR4); in pxa_camera_setup_cicr()
1282 cicr0 = (cicr0 & CICR0_ENB) | (pcdev->platform_flags & PXA_CAMERA_MASTER ? in pxa_camera_setup_cicr()
1285 __raw_writel(cicr0, pcdev->base + CICR0); in pxa_camera_setup_cicr()
1306 static int pxa_buffer_init(struct pxa_camera_dev *pcdev, in pxa_buffer_init() argument
1311 int nb_channels = pcdev->channels; in pxa_buffer_init()
1332 dev_err(pcdev_to_dev(pcdev), in pxa_buffer_init()
1337 ret = pxa_init_dma_channel(pcdev, buf, i, in pxa_buffer_init()
1352 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue); in pxac_vb2_cleanup() local
1354 dev_dbg(pcdev_to_dev(pcdev), in pxac_vb2_cleanup()
1362 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue); in pxac_vb2_queue() local
1364 dev_dbg(pcdev_to_dev(pcdev), in pxac_vb2_queue()
1366 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0), in pxac_vb2_queue()
1367 pcdev->active); in pxac_vb2_queue()
1369 list_add_tail(&buf->queue, &pcdev->capture); in pxac_vb2_queue()
1371 pxa_dma_add_tail_buf(pcdev, buf); in pxac_vb2_queue()
1382 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue); in pxac_vb2_prepare() local
1389 switch (pcdev->channels) { in pxac_vb2_prepare()
1392 vb2_set_plane_payload(vb, 0, pcdev->current_pix.sizeimage); in pxac_vb2_prepare()
1398 dev_dbg(pcdev_to_dev(pcdev), in pxac_vb2_prepare()
1400 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0)); in pxac_vb2_prepare()
1402 WARN_ON(!pcdev->current_fmt); in pxac_vb2_prepare()
1419 pxa_video_buf_set_actdma(pcdev, buf); in pxac_vb2_prepare()
1426 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue); in pxac_vb2_init() local
1429 dev_dbg(pcdev_to_dev(pcdev), in pxac_vb2_init()
1431 __func__, pcdev->channels); in pxac_vb2_init()
1433 return pxa_buffer_init(pcdev, buf); in pxac_vb2_init()
1441 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq); in pxac_vb2_queue_setup() local
1442 int size = pcdev->current_pix.sizeimage; in pxac_vb2_queue_setup()
1444 dev_dbg(pcdev_to_dev(pcdev), in pxac_vb2_queue_setup()
1456 switch (pcdev->channels) { in pxac_vb2_queue_setup()
1473 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq); in pxac_vb2_start_streaming() local
1475 dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n", in pxac_vb2_start_streaming()
1476 __func__, count, pcdev->active); in pxac_vb2_start_streaming()
1478 pcdev->buf_sequence = 0; in pxac_vb2_start_streaming()
1479 if (!pcdev->active) in pxac_vb2_start_streaming()
1480 pxa_camera_start_capture(pcdev); in pxac_vb2_start_streaming()
1487 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq); in pxac_vb2_stop_streaming() local
1490 dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n", in pxac_vb2_stop_streaming()
1491 __func__, pcdev->active); in pxac_vb2_stop_streaming()
1492 pxa_camera_stop_capture(pcdev); in pxac_vb2_stop_streaming()
1494 list_for_each_entry_safe(buf, tmp, &pcdev->capture, queue) in pxac_vb2_stop_streaming()
1495 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR); in pxac_vb2_stop_streaming()
1510 static int pxa_camera_init_videobuf2(struct pxa_camera_dev *pcdev) in pxa_camera_init_videobuf2() argument
1513 struct vb2_queue *vq = &pcdev->vb2_vq; in pxa_camera_init_videobuf2()
1518 vq->drv_priv = pcdev; in pxa_camera_init_videobuf2()
1521 vq->dev = pcdev->v4l2_dev.dev; in pxa_camera_init_videobuf2()
1525 vq->lock = &pcdev->mlock; in pxa_camera_init_videobuf2()
1528 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_init_videobuf2()
1537 static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev) in pxa_camera_set_bus_param() argument
1539 unsigned int bus_width = pcdev->current_fmt->host_fmt->bits_per_sample; in pxa_camera_set_bus_param()
1541 u32 pixfmt = pcdev->current_fmt->host_fmt->fourcc; in pxa_camera_set_bus_param()
1545 if (!((1 << (bus_width - 1)) & pcdev->width_flags)) { in pxa_camera_set_bus_param()
1546 dev_err(pcdev_to_dev(pcdev), "Unsupported bus width %u", in pxa_camera_set_bus_param()
1551 pcdev->channels = 1; in pxa_camera_set_bus_param()
1555 if (pcdev->platform_flags & PXA_CAMERA_MASTER) in pxa_camera_set_bus_param()
1560 if (pcdev->platform_flags & PXA_CAMERA_HSP) in pxa_camera_set_bus_param()
1565 if (pcdev->platform_flags & PXA_CAMERA_VSP) in pxa_camera_set_bus_param()
1570 if (pcdev->platform_flags & PXA_CAMERA_PCP) in pxa_camera_set_bus_param()
1576 ret = sensor_call(pcdev, pad, get_mbus_config, 0, &cfg); in pxa_camera_set_bus_param()
1578 dev_err(pcdev_to_dev(pcdev), in pxa_camera_set_bus_param()
1597 dev_err(pcdev_to_dev(pcdev), in pxa_camera_set_bus_param()
1603 dev_err(pcdev_to_dev(pcdev), in pxa_camera_set_bus_param()
1609 pxa_camera_setup_cicr(pcdev, cfg.bus.parallel.flags, pixfmt); in pxa_camera_set_bus_param()
1639 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev); in pxa_camera_get_formats() local
1647 ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, &code); in pxa_camera_get_formats()
1654 dev_err(pcdev_to_dev(pcdev), in pxa_camera_get_formats()
1666 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_get_formats()
1677 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_get_formats()
1685 dev_dbg(pcdev_to_dev(pcdev), in pxa_camera_get_formats()
1702 static int pxa_camera_build_formats(struct pxa_camera_dev *pcdev) in pxa_camera_build_formats() argument
1706 xlate = pxa_mbus_build_fmts_xlate(&pcdev->v4l2_dev, pcdev->sensor, in pxa_camera_build_formats()
1711 pcdev->user_formats = xlate; in pxa_camera_build_formats()
1715 static void pxa_camera_destroy_formats(struct pxa_camera_dev *pcdev) in pxa_camera_destroy_formats() argument
1717 kfree(pcdev->user_formats); in pxa_camera_destroy_formats()
1731 struct pxa_camera_dev *pcdev = video_drvdata(file); in pxac_vidioc_g_register() local
1736 reg->val = __raw_readl(pcdev->base + reg->reg); in pxac_vidioc_g_register()
1744 struct pxa_camera_dev *pcdev = video_drvdata(file); in pxac_vidioc_s_register() local
1750 __raw_writel(reg->val, pcdev->base + reg->reg); in pxac_vidioc_s_register()
1758 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_vidioc_enum_fmt_vid_cap() local
1762 for (idx = 0; pcdev->user_formats[idx].code; idx++); in pxac_vidioc_enum_fmt_vid_cap()
1766 format = pcdev->user_formats[f->index].host_fmt; in pxac_vidioc_enum_fmt_vid_cap()
1774 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_vidioc_g_fmt_vid_cap() local
1777 pix->width = pcdev->current_pix.width; in pxac_vidioc_g_fmt_vid_cap()
1778 pix->height = pcdev->current_pix.height; in pxac_vidioc_g_fmt_vid_cap()
1779 pix->bytesperline = pcdev->current_pix.bytesperline; in pxac_vidioc_g_fmt_vid_cap()
1780 pix->sizeimage = pcdev->current_pix.sizeimage; in pxac_vidioc_g_fmt_vid_cap()
1781 pix->field = pcdev->current_pix.field; in pxac_vidioc_g_fmt_vid_cap()
1782 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc; in pxac_vidioc_g_fmt_vid_cap()
1783 pix->colorspace = pcdev->current_pix.colorspace; in pxac_vidioc_g_fmt_vid_cap()
1784 dev_dbg(pcdev_to_dev(pcdev), "current_fmt->fourcc: 0x%08x\n", in pxac_vidioc_g_fmt_vid_cap()
1785 pcdev->current_fmt->host_fmt->fourcc); in pxac_vidioc_g_fmt_vid_cap()
1792 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_vidioc_try_fmt_vid_cap() local
1806 xlate = pxa_mbus_xlate_by_fourcc(pcdev->user_formats, pixfmt); in pxac_vidioc_try_fmt_vid_cap()
1808 dev_warn(pcdev_to_dev(pcdev), "Format %x not found\n", pixfmt); in pxac_vidioc_try_fmt_vid_cap()
1823 ret = sensor_call(pcdev, pad, set_fmt, &pad_state, &format); in pxac_vidioc_try_fmt_vid_cap()
1837 dev_err(pcdev_to_dev(pcdev), "Field type %d unsupported.\n", in pxac_vidioc_try_fmt_vid_cap()
1859 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_vidioc_s_fmt_vid_cap() local
1868 dev_dbg(pcdev_to_dev(pcdev), in pxac_vidioc_s_fmt_vid_cap()
1872 spin_lock_irqsave(&pcdev->lock, flags); in pxac_vidioc_s_fmt_vid_cap()
1873 is_busy = pcdev->active || vb2_is_busy(&pcdev->vb2_vq); in pxac_vidioc_s_fmt_vid_cap()
1874 spin_unlock_irqrestore(&pcdev->lock, flags); in pxac_vidioc_s_fmt_vid_cap()
1883 xlate = pxa_mbus_xlate_by_fourcc(pcdev->user_formats, in pxac_vidioc_s_fmt_vid_cap()
1886 ret = sensor_call(pcdev, pad, set_fmt, NULL, &format); in pxac_vidioc_s_fmt_vid_cap()
1888 dev_warn(pcdev_to_dev(pcdev), in pxac_vidioc_s_fmt_vid_cap()
1892 dev_warn(pcdev_to_dev(pcdev), in pxac_vidioc_s_fmt_vid_cap()
1898 pcdev->current_fmt = xlate; in pxac_vidioc_s_fmt_vid_cap()
1899 pcdev->current_pix = *pix; in pxac_vidioc_s_fmt_vid_cap()
1901 ret = pxa_camera_set_bus_param(pcdev); in pxac_vidioc_s_fmt_vid_cap()
1941 static int pxac_sensor_set_power(struct pxa_camera_dev *pcdev, int on) in pxac_sensor_set_power() argument
1945 ret = sensor_call(pcdev, core, s_power, on); in pxac_sensor_set_power()
1949 dev_warn(pcdev_to_dev(pcdev), in pxac_sensor_set_power()
1959 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_fops_camera_open() local
1962 mutex_lock(&pcdev->mlock); in pxac_fops_camera_open()
1970 ret = pxac_sensor_set_power(pcdev, 1); in pxac_fops_camera_open()
1974 mutex_unlock(&pcdev->mlock); in pxac_fops_camera_open()
1980 struct pxa_camera_dev *pcdev = video_drvdata(filp); in pxac_fops_camera_release() local
1984 mutex_lock(&pcdev->mlock); in pxac_fops_camera_release()
1991 ret = pxac_sensor_set_power(pcdev, 0); in pxac_fops_camera_release()
1993 mutex_unlock(&pcdev->mlock); in pxac_fops_camera_release()
2051 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev); in pxa_camera_sensor_bound() local
2052 struct video_device *vdev = &pcdev->vdev; in pxa_camera_sensor_bound()
2053 struct v4l2_pix_format *pix = &pcdev->current_pix; in pxa_camera_sensor_bound()
2059 dev_info(pcdev_to_dev(pcdev), "%s(): trying to bind a device\n", in pxa_camera_sensor_bound()
2061 mutex_lock(&pcdev->mlock); in pxa_camera_sensor_bound()
2064 vdev->lock = &pcdev->mlock; in pxa_camera_sensor_bound()
2065 pcdev->sensor = subdev; in pxa_camera_sensor_bound()
2066 pcdev->vdev.queue = &pcdev->vb2_vq; in pxa_camera_sensor_bound()
2067 pcdev->vdev.v4l2_dev = &pcdev->v4l2_dev; in pxa_camera_sensor_bound()
2068 pcdev->vdev.ctrl_handler = subdev->ctrl_handler; in pxa_camera_sensor_bound()
2069 video_set_drvdata(&pcdev->vdev, pcdev); in pxa_camera_sensor_bound()
2071 err = pxa_camera_build_formats(pcdev); in pxa_camera_sensor_bound()
2073 dev_err(pcdev_to_dev(pcdev), "building formats failed: %d\n", in pxa_camera_sensor_bound()
2078 pcdev->current_fmt = pcdev->user_formats; in pxa_camera_sensor_bound()
2084 pcdev->current_fmt->host_fmt); in pxa_camera_sensor_bound()
2086 pxa_mbus_image_size(pcdev->current_fmt->host_fmt, in pxa_camera_sensor_bound()
2088 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc; in pxa_camera_sensor_bound()
2089 v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code); in pxa_camera_sensor_bound()
2091 err = pxac_sensor_set_power(pcdev, 1); in pxa_camera_sensor_bound()
2095 err = sensor_call(pcdev, pad, set_fmt, NULL, &format); in pxa_camera_sensor_bound()
2103 err = pxa_camera_init_videobuf2(pcdev); in pxa_camera_sensor_bound()
2107 err = video_register_device(&pcdev->vdev, VFL_TYPE_VIDEO, -1); in pxa_camera_sensor_bound()
2110 pcdev->sensor = NULL; in pxa_camera_sensor_bound()
2112 dev_info(pcdev_to_dev(pcdev), in pxa_camera_sensor_bound()
2118 err = pxac_sensor_set_power(pcdev, 0); in pxa_camera_sensor_bound()
2120 mutex_unlock(&pcdev->mlock); in pxa_camera_sensor_bound()
2128 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(notifier->v4l2_dev); in pxa_camera_sensor_unbind() local
2130 mutex_lock(&pcdev->mlock); in pxa_camera_sensor_unbind()
2131 dev_info(pcdev_to_dev(pcdev), in pxa_camera_sensor_unbind()
2136 __raw_writel(0x3ff, pcdev->base + CICR0); in pxa_camera_sensor_unbind()
2139 pxa_dma_stop_channels(pcdev); in pxa_camera_sensor_unbind()
2141 pxa_camera_destroy_formats(pcdev); in pxa_camera_sensor_unbind()
2143 video_unregister_device(&pcdev->vdev); in pxa_camera_sensor_unbind()
2144 pcdev->sensor = NULL; in pxa_camera_sensor_unbind()
2146 mutex_unlock(&pcdev->mlock); in pxa_camera_sensor_unbind()
2159 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev); in pxa_camera_suspend() local
2162 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR0); in pxa_camera_suspend()
2163 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR1); in pxa_camera_suspend()
2164 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR2); in pxa_camera_suspend()
2165 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3); in pxa_camera_suspend()
2166 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4); in pxa_camera_suspend()
2168 if (pcdev->sensor) in pxa_camera_suspend()
2169 ret = pxac_sensor_set_power(pcdev, 0); in pxa_camera_suspend()
2176 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev); in pxa_camera_resume() local
2179 __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0); in pxa_camera_resume()
2180 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1); in pxa_camera_resume()
2181 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2); in pxa_camera_resume()
2182 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR3); in pxa_camera_resume()
2183 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4); in pxa_camera_resume()
2185 if (pcdev->sensor) { in pxa_camera_resume()
2186 ret = pxac_sensor_set_power(pcdev, 1); in pxa_camera_resume()
2190 if (!ret && pcdev->active) in pxa_camera_resume()
2191 pxa_camera_start_capture(pcdev); in pxa_camera_resume()
2197 struct pxa_camera_dev *pcdev) in pxa_camera_pdata_from_dt() argument
2206 pcdev->platform_flags |= PXA_CAMERA_MCLK_EN; in pxa_camera_pdata_from_dt()
2207 pcdev->mclk = mclk_rate; in pxa_camera_pdata_from_dt()
2224 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_4; in pxa_camera_pdata_from_dt()
2227 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_5; in pxa_camera_pdata_from_dt()
2230 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_8; in pxa_camera_pdata_from_dt()
2233 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_9; in pxa_camera_pdata_from_dt()
2236 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10; in pxa_camera_pdata_from_dt()
2243 pcdev->platform_flags |= PXA_CAMERA_MASTER; in pxa_camera_pdata_from_dt()
2245 pcdev->platform_flags |= PXA_CAMERA_HSP; in pxa_camera_pdata_from_dt()
2247 pcdev->platform_flags |= PXA_CAMERA_VSP; in pxa_camera_pdata_from_dt()
2249 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN | PXA_CAMERA_PCP; in pxa_camera_pdata_from_dt()
2251 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN; in pxa_camera_pdata_from_dt()
2253 asd = v4l2_async_nf_add_fwnode_remote(&pcdev->notifier, in pxa_camera_pdata_from_dt()
2266 struct pxa_camera_dev *pcdev; in pxa_camera_probe() local
2282 pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev), GFP_KERNEL); in pxa_camera_probe()
2283 if (!pcdev) { in pxa_camera_probe()
2288 pcdev->clk = devm_clk_get(&pdev->dev, NULL); in pxa_camera_probe()
2289 if (IS_ERR(pcdev->clk)) in pxa_camera_probe()
2290 return PTR_ERR(pcdev->clk); in pxa_camera_probe()
2292 v4l2_async_nf_init(&pcdev->notifier); in pxa_camera_probe()
2293 pcdev->res = res; in pxa_camera_probe()
2294 pcdev->pdata = pdev->dev.platform_data; in pxa_camera_probe()
2295 if (pcdev->pdata) { in pxa_camera_probe()
2298 pcdev->platform_flags = pcdev->pdata->flags; in pxa_camera_probe()
2299 pcdev->mclk = pcdev->pdata->mclk_10khz * 10000; in pxa_camera_probe()
2300 asd = v4l2_async_nf_add_i2c(&pcdev->notifier, in pxa_camera_probe()
2301 pcdev->pdata->sensor_i2c_adapter_id, in pxa_camera_probe()
2302 pcdev->pdata->sensor_i2c_address, in pxa_camera_probe()
2307 err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev); in pxa_camera_probe()
2314 if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 | in pxa_camera_probe()
2321 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10; in pxa_camera_probe()
2323 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8) in pxa_camera_probe()
2324 pcdev->width_flags = 1 << 7; in pxa_camera_probe()
2325 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9) in pxa_camera_probe()
2326 pcdev->width_flags |= 1 << 8; in pxa_camera_probe()
2327 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10) in pxa_camera_probe()
2328 pcdev->width_flags |= 1 << 9; in pxa_camera_probe()
2329 if (!pcdev->mclk) { in pxa_camera_probe()
2332 pcdev->mclk = 20000000; in pxa_camera_probe()
2335 pcdev->mclk_divisor = mclk_get_divisor(pdev, pcdev); in pxa_camera_probe()
2337 INIT_LIST_HEAD(&pcdev->capture); in pxa_camera_probe()
2338 spin_lock_init(&pcdev->lock); in pxa_camera_probe()
2339 mutex_init(&pcdev->mlock); in pxa_camera_probe()
2348 pcdev->irq = irq; in pxa_camera_probe()
2349 pcdev->base = base; in pxa_camera_probe()
2352 pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y"); in pxa_camera_probe()
2353 if (IS_ERR(pcdev->dma_chans[0])) { in pxa_camera_probe()
2355 return PTR_ERR(pcdev->dma_chans[0]); in pxa_camera_probe()
2358 pcdev->dma_chans[1] = dma_request_chan(&pdev->dev, "CI_U"); in pxa_camera_probe()
2359 if (IS_ERR(pcdev->dma_chans[1])) { in pxa_camera_probe()
2361 err = PTR_ERR(pcdev->dma_chans[1]); in pxa_camera_probe()
2365 pcdev->dma_chans[2] = dma_request_chan(&pdev->dev, "CI_V"); in pxa_camera_probe()
2366 if (IS_ERR(pcdev->dma_chans[2])) { in pxa_camera_probe()
2368 err = PTR_ERR(pcdev->dma_chans[2]); in pxa_camera_probe()
2373 config.src_addr = pcdev->res->start + CIBR0 + i * 8; in pxa_camera_probe()
2374 err = dmaengine_slave_config(pcdev->dma_chans[i], &config); in pxa_camera_probe()
2383 err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0, in pxa_camera_probe()
2384 PXA_CAM_DRV_NAME, pcdev); in pxa_camera_probe()
2390 tasklet_setup(&pcdev->task_eof, pxa_camera_eof); in pxa_camera_probe()
2392 pxa_camera_activate(pcdev); in pxa_camera_probe()
2394 platform_set_drvdata(pdev, pcdev); in pxa_camera_probe()
2395 err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev); in pxa_camera_probe()
2399 err = pxa_camera_init_videobuf2(pcdev); in pxa_camera_probe()
2403 pcdev->notifier.ops = &pxa_camera_sensor_ops; in pxa_camera_probe()
2404 err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier); in pxa_camera_probe()
2410 v4l2_async_nf_cleanup(&pcdev->notifier); in pxa_camera_probe()
2411 v4l2_device_unregister(&pcdev->v4l2_dev); in pxa_camera_probe()
2413 pxa_camera_deactivate(pcdev); in pxa_camera_probe()
2414 tasklet_kill(&pcdev->task_eof); in pxa_camera_probe()
2416 dma_release_channel(pcdev->dma_chans[2]); in pxa_camera_probe()
2418 dma_release_channel(pcdev->dma_chans[1]); in pxa_camera_probe()
2420 dma_release_channel(pcdev->dma_chans[0]); in pxa_camera_probe()
2426 struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev); in pxa_camera_remove() local
2428 pxa_camera_deactivate(pcdev); in pxa_camera_remove()
2429 tasklet_kill(&pcdev->task_eof); in pxa_camera_remove()
2430 dma_release_channel(pcdev->dma_chans[0]); in pxa_camera_remove()
2431 dma_release_channel(pcdev->dma_chans[1]); in pxa_camera_remove()
2432 dma_release_channel(pcdev->dma_chans[2]); in pxa_camera_remove()
2434 v4l2_async_nf_unregister(&pcdev->notifier); in pxa_camera_remove()
2435 v4l2_async_nf_cleanup(&pcdev->notifier); in pxa_camera_remove()
2437 v4l2_device_unregister(&pcdev->v4l2_dev); in pxa_camera_remove()