Lines Matching refs:pcdev
777 static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev)
779 return pcdev->v4l2_dev.dev;
787 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
792 struct pxa_camera_dev *pcdev = data;
794 pxa_camera_dma_irq(pcdev, DMA_Y);
799 struct pxa_camera_dev *pcdev = data;
801 pxa_camera_dma_irq(pcdev, DMA_U);
806 struct pxa_camera_dev *pcdev = data;
808 pxa_camera_dma_irq(pcdev, DMA_V);
813 * @pcdev: pxa camera device
823 static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
827 struct dma_chan *dma_chan = pcdev->dma_chans[channel];
833 dev_err(pcdev_to_dev(pcdev),
838 tx->callback_param = pcdev;
854 dev_dbg(pcdev_to_dev(pcdev),
861 static void pxa_videobuf_set_actdma(struct pxa_camera_dev *pcdev,
871 * @pcdev: pxa camera device
876 static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev)
880 for (i = 0; i < pcdev->channels; i++) {
881 dev_dbg(pcdev_to_dev(pcdev),
883 dma_async_issue_pending(pcdev->dma_chans[i]);
887 static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
891 for (i = 0; i < pcdev->channels; i++) {
892 dev_dbg(pcdev_to_dev(pcdev),
894 dmaengine_terminate_all(pcdev->dma_chans[i]);
898 static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
903 for (i = 0; i < pcdev->channels; i++) {
905 dev_dbg(pcdev_to_dev(pcdev),
913 * @pcdev: camera device
919 static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev)
923 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__);
924 __raw_writel(__raw_readl(pcdev->base + CISR), pcdev->base + CISR);
926 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB;
928 __raw_writel(cicr0, pcdev->base + CICR0);
931 static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
935 pxa_dma_stop_channels(pcdev);
937 cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB;
938 __raw_writel(cicr0, pcdev->base + CICR0);
940 pcdev->active = NULL;
941 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__);
944 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
954 vbuf->sequence = pcdev->buf_sequence++;
957 dev_dbg(pcdev_to_dev(pcdev), "%s dequeued buffer (buf=0x%p)\n",
960 if (list_empty(&pcdev->capture)) {
961 pxa_camera_stop_capture(pcdev);
965 pcdev->active = list_entry(pcdev->capture.next,
971 * @pcdev: camera device
980 * - a videobuffer is queued on the pcdev->capture list
987 static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev,
993 dev_dbg(pcdev_to_dev(pcdev),
995 __func__, pcdev->active, is_dma_stopped);
997 if (pcdev->active && is_dma_stopped)
998 pxa_camera_start_capture(pcdev);
1001 static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
1011 spin_lock_irqsave(&pcdev->lock, flags);
1013 camera_status = __raw_readl(pcdev->base + CISR);
1014 dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n",
1017 if (pcdev->channels == 3)
1021 * pcdev->active should not be NULL in DMA irq handler.
1027 * capture and restart it (and thus set pcdev->active to NULL). But the
1032 if (!pcdev->active)
1035 buf = pcdev->active;
1053 last_buf = list_entry(pcdev->capture.prev,
1055 last_status = dma_async_is_tx_complete(pcdev->dma_chans[chan],
1060 dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n",
1062 pxa_camera_stop_capture(pcdev);
1063 list_for_each_entry(buf, &pcdev->capture, queue)
1064 pxa_dma_add_tail_buf(pcdev, buf);
1065 pxa_camera_start_capture(pcdev);
1070 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
1071 pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
1076 spin_unlock_irqrestore(&pcdev->lock, flags);
1080 struct pxa_camera_dev *pcdev)
1082 unsigned long mclk = pcdev->mclk;
1086 lcdclk = clk_get_rate(pcdev->clk);
1087 pcdev->ciclk = lcdclk;
1100 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
1101 pcdev->mclk = lcdclk / (2 * (div + 1));
1109 static void recalculate_fifo_timeout(struct pxa_camera_dev *pcdev,
1113 u32 ciclk_per_pixel = pcdev->ciclk / pclk + 1;
1115 __raw_writel(ciclk_per_pixel, pcdev->base + CITOR);
1118 static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
1123 __raw_writel(0x3ff, pcdev->base + CICR0);
1125 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
1127 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
1129 if (pcdev->platform_flags & PXA_CAMERA_PCP)
1131 if (pcdev->platform_flags & PXA_CAMERA_HSP)
1133 if (pcdev->platform_flags & PXA_CAMERA_VSP)
1136 __raw_writel(pcdev->mclk_divisor | cicr4, pcdev->base + CICR4);
1138 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
1140 recalculate_fifo_timeout(pcdev, pcdev->mclk);
1143 recalculate_fifo_timeout(pcdev, 13000000);
1145 clk_prepare_enable(pcdev->clk);
1148 static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
1150 clk_disable_unprepare(pcdev->clk);
1155 struct pxa_camera_dev *pcdev = from_tasklet(pcdev, t, task_eof);
1159 dev_dbg(pcdev_to_dev(pcdev),
1161 __raw_readl(pcdev->base + CISR));
1164 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
1165 __raw_writel(cifr, pcdev->base + CIFR);
1167 pcdev->active = list_first_entry(&pcdev->capture,
1169 buf = pcdev->active;
1170 pxa_videobuf_set_actdma(pcdev, buf);
1172 pxa_dma_start_channels(pcdev);
1177 struct pxa_camera_dev *pcdev = data;
1180 status = __raw_readl(pcdev->base + CISR);
1181 dev_dbg(pcdev_to_dev(pcdev),
1187 __raw_writel(status, pcdev->base + CISR);
1190 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM;
1191 __raw_writel(cicr0, pcdev->base + CICR0);
1192 tasklet_schedule(&pcdev->task_eof);
1198 static void pxa_camera_setup_cicr(struct pxa_camera_dev *pcdev,
1203 int ret = sensor_call(pcdev, sensor, g_skip_top_lines, &y_skip_top);
1212 switch (pcdev->current_fmt->host_fmt->bits_per_sample) {
1231 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
1233 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
1242 cicr0 = __raw_readl(pcdev->base + CICR0);
1244 __raw_writel(cicr0 & ~CICR0_ENB, pcdev->base + CICR0);
1246 cicr1 = CICR1_PPL_VAL(pcdev->current_pix.width - 1) | bpp | dw;
1250 pcdev->channels = 3;
1276 cicr3 = CICR3_LPF_VAL(pcdev->current_pix.height - 1) |
1278 cicr4 |= pcdev->mclk_divisor;
1280 __raw_writel(cicr1, pcdev->base + CICR1);
1281 __raw_writel(cicr2, pcdev->base + CICR2);
1282 __raw_writel(cicr3, pcdev->base + CICR3);
1283 __raw_writel(cicr4, pcdev->base + CICR4);
1286 cicr0 = (cicr0 & CICR0_ENB) | (pcdev->platform_flags & PXA_CAMERA_MASTER ?
1289 __raw_writel(cicr0, pcdev->base + CICR0);
1310 static int pxa_buffer_init(struct pxa_camera_dev *pcdev,
1315 int nb_channels = pcdev->channels;
1336 dev_err(pcdev_to_dev(pcdev),
1341 ret = pxa_init_dma_channel(pcdev, buf, i,
1356 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
1358 dev_dbg(pcdev_to_dev(pcdev),
1366 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
1368 dev_dbg(pcdev_to_dev(pcdev),
1370 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0),
1371 pcdev->active);
1373 list_add_tail(&buf->queue, &pcdev->capture);
1375 pxa_dma_add_tail_buf(pcdev, buf);
1386 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
1393 switch (pcdev->channels) {
1396 vb2_set_plane_payload(vb, 0, pcdev->current_pix.sizeimage);
1402 dev_dbg(pcdev_to_dev(pcdev),
1404 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0));
1406 WARN_ON(!pcdev->current_fmt);
1423 pxa_videobuf_set_actdma(pcdev, buf);
1430 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
1433 dev_dbg(pcdev_to_dev(pcdev),
1435 __func__, pcdev->channels);
1437 return pxa_buffer_init(pcdev, buf);
1445 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
1446 int size = pcdev->current_pix.sizeimage;
1448 dev_dbg(pcdev_to_dev(pcdev),
1460 switch (pcdev->channels) {
1477 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
1479 dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n",
1480 __func__, count, pcdev->active);
1482 pcdev->buf_sequence = 0;
1483 if (!pcdev->active)
1484 pxa_camera_start_capture(pcdev);
1491 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
1494 dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
1495 __func__, pcdev->active);
1496 pxa_camera_stop_capture(pcdev);
1498 list_for_each_entry_safe(buf, tmp, &pcdev->capture, queue)
1499 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
1514 static int pxa_camera_init_videobuf2(struct pxa_camera_dev *pcdev)
1517 struct vb2_queue *vq = &pcdev->vb2_vq;
1522 vq->drv_priv = pcdev;
1525 vq->dev = pcdev->v4l2_dev.dev;
1529 vq->lock = &pcdev->mlock;
1532 dev_dbg(pcdev_to_dev(pcdev),
1541 static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
1543 unsigned int bus_width = pcdev->current_fmt->host_fmt->bits_per_sample;
1545 u32 pixfmt = pcdev->current_fmt->host_fmt->fourcc;
1549 if (!((1 << (bus_width - 1)) & pcdev->width_flags)) {
1550 dev_err(pcdev_to_dev(pcdev), "Unsupported bus width %u",
1555 pcdev->channels = 1;
1559 if (pcdev->platform_flags & PXA_CAMERA_MASTER)
1564 if (pcdev->platform_flags & PXA_CAMERA_HSP)
1569 if (pcdev->platform_flags & PXA_CAMERA_VSP)
1574 if (pcdev->platform_flags & PXA_CAMERA_PCP)
1581 ret = sensor_call(pcdev, pad, set_mbus_config, 0, &cfg);
1583 dev_err(pcdev_to_dev(pcdev),
1600 dev_err(pcdev_to_dev(pcdev),
1606 dev_err(pcdev_to_dev(pcdev),
1612 pxa_camera_setup_cicr(pcdev, cfg.flags, pixfmt);
1642 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev);
1650 ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, &code);
1657 dev_err(pcdev_to_dev(pcdev),
1669 dev_dbg(pcdev_to_dev(pcdev),
1680 dev_dbg(pcdev_to_dev(pcdev),
1688 dev_dbg(pcdev_to_dev(pcdev),
1705 static int pxa_camera_build_formats(struct pxa_camera_dev *pcdev)
1709 xlate = pxa_mbus_build_fmts_xlate(&pcdev->v4l2_dev, pcdev->sensor,
1714 pcdev->user_formats = xlate;
1718 static void pxa_camera_destroy_formats(struct pxa_camera_dev *pcdev)
1720 kfree(pcdev->user_formats);
1734 struct pxa_camera_dev *pcdev = video_drvdata(file);
1739 reg->val = __raw_readl(pcdev->base + reg->reg);
1747 struct pxa_camera_dev *pcdev = video_drvdata(file);
1753 __raw_writel(reg->val, pcdev->base + reg->reg);
1761 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1765 for (idx = 0; pcdev->user_formats[idx].code; idx++);
1769 format = pcdev->user_formats[f->index].host_fmt;
1777 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1780 pix->width = pcdev->current_pix.width;
1781 pix->height = pcdev->current_pix.height;
1782 pix->bytesperline = pcdev->current_pix.bytesperline;
1783 pix->sizeimage = pcdev->current_pix.sizeimage;
1784 pix->field = pcdev->current_pix.field;
1785 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
1786 pix->colorspace = pcdev->current_pix.colorspace;
1787 dev_dbg(pcdev_to_dev(pcdev), "current_fmt->fourcc: 0x%08x\n",
1788 pcdev->current_fmt->host_fmt->fourcc);
1795 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1806 xlate = pxa_mbus_xlate_by_fourcc(pcdev->user_formats, pixfmt);
1808 dev_warn(pcdev_to_dev(pcdev), "Format %x not found\n", pixfmt);
1823 ret = sensor_call(pcdev, pad, set_fmt, &pad_cfg, &format);
1837 dev_err(pcdev_to_dev(pcdev), "Field type %d unsupported.\n",
1859 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1868 dev_dbg(pcdev_to_dev(pcdev),
1872 spin_lock_irqsave(&pcdev->lock, flags);
1873 is_busy = pcdev->active || vb2_is_busy(&pcdev->vb2_vq);
1874 spin_unlock_irqrestore(&pcdev->lock, flags);
1883 xlate = pxa_mbus_xlate_by_fourcc(pcdev->user_formats,
1886 ret = sensor_call(pcdev, pad, set_fmt, NULL, &format);
1888 dev_warn(pcdev_to_dev(pcdev),
1892 dev_warn(pcdev_to_dev(pcdev),
1898 pcdev->current_fmt = xlate;
1899 pcdev->current_pix = *pix;
1901 ret = pxa_camera_set_bus_param(pcdev);
1941 static int pxac_sensor_set_power(struct pxa_camera_dev *pcdev, int on)
1945 ret = sensor_call(pcdev, core, s_power, on);
1949 dev_warn(pcdev_to_dev(pcdev),
1959 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1962 mutex_lock(&pcdev->mlock);
1970 ret = pxac_sensor_set_power(pcdev, 1);
1974 mutex_unlock(&pcdev->mlock);
1980 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1984 mutex_lock(&pcdev->mlock);
1991 ret = pxac_sensor_set_power(pcdev, 0);
1993 mutex_unlock(&pcdev->mlock);
2054 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev);
2055 struct video_device *vdev = &pcdev->vdev;
2056 struct v4l2_pix_format *pix = &pcdev->current_pix;
2062 dev_info(pcdev_to_dev(pcdev), "%s(): trying to bind a device\n",
2064 mutex_lock(&pcdev->mlock);
2067 vdev->lock = &pcdev->mlock;
2068 pcdev->sensor = subdev;
2069 pcdev->vdev.queue = &pcdev->vb2_vq;
2070 pcdev->vdev.v4l2_dev = &pcdev->v4l2_dev;
2071 pcdev->vdev.ctrl_handler = subdev->ctrl_handler;
2072 video_set_drvdata(&pcdev->vdev, pcdev);
2074 err = pxa_camera_build_formats(pcdev);
2076 dev_err(pcdev_to_dev(pcdev), "building formats failed: %d\n",
2081 pcdev->current_fmt = pcdev->user_formats;
2087 pcdev->current_fmt->host_fmt);
2089 pxa_mbus_image_size(pcdev->current_fmt->host_fmt,
2091 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
2092 v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code);
2094 err = pxac_sensor_set_power(pcdev, 1);
2098 err = sensor_call(pcdev, pad, set_fmt, NULL, &format);
2106 err = pxa_camera_init_videobuf2(pcdev);
2110 err = video_register_device(&pcdev->vdev, VFL_TYPE_VIDEO, -1);
2113 pcdev->sensor = NULL;
2115 dev_info(pcdev_to_dev(pcdev),
2121 err = pxac_sensor_set_power(pcdev, 0);
2123 mutex_unlock(&pcdev->mlock);
2131 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(notifier->v4l2_dev);
2133 mutex_lock(&pcdev->mlock);
2134 dev_info(pcdev_to_dev(pcdev),
2139 __raw_writel(0x3ff, pcdev->base + CICR0);
2142 pxa_dma_stop_channels(pcdev);
2144 pxa_camera_destroy_formats(pcdev);
2146 if (pcdev->mclk_clk) {
2147 v4l2_clk_unregister(pcdev->mclk_clk);
2148 pcdev->mclk_clk = NULL;
2151 video_unregister_device(&pcdev->vdev);
2152 pcdev->sensor = NULL;
2154 mutex_unlock(&pcdev->mlock);
2167 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev);
2170 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR0);
2171 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR1);
2172 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR2);
2173 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3);
2174 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4);
2176 if (pcdev->sensor)
2177 ret = pxac_sensor_set_power(pcdev, 0);
2184 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev);
2187 __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0);
2188 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1);
2189 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2);
2190 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR3);
2191 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4);
2193 if (pcdev->sensor) {
2194 ret = pxac_sensor_set_power(pcdev, 1);
2198 if (!ret && pcdev->active)
2199 pxa_camera_start_capture(pcdev);
2205 struct pxa_camera_dev *pcdev,
2214 pcdev->platform_flags |= PXA_CAMERA_MCLK_EN;
2215 pcdev->mclk = mclk_rate;
2232 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_4;
2235 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_5;
2238 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_8;
2241 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_9;
2244 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
2251 pcdev->platform_flags |= PXA_CAMERA_MASTER;
2253 pcdev->platform_flags |= PXA_CAMERA_HSP;
2255 pcdev->platform_flags |= PXA_CAMERA_VSP;
2257 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN | PXA_CAMERA_PCP;
2259 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN;
2276 struct pxa_camera_dev *pcdev;
2293 pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev), GFP_KERNEL);
2294 if (!pcdev) {
2295 dev_err(&pdev->dev, "Could not allocate pcdev\n");
2299 pcdev->clk = devm_clk_get(&pdev->dev, NULL);
2300 if (IS_ERR(pcdev->clk))
2301 return PTR_ERR(pcdev->clk);
2303 pcdev->res = res;
2305 pcdev->pdata = pdev->dev.platform_data;
2306 if (pcdev->pdata) {
2307 pcdev->platform_flags = pcdev->pdata->flags;
2308 pcdev->mclk = pcdev->pdata->mclk_10khz * 10000;
2309 pcdev->asd.match_type = V4L2_ASYNC_MATCH_I2C;
2310 pcdev->asd.match.i2c.adapter_id =
2311 pcdev->pdata->sensor_i2c_adapter_id;
2312 pcdev->asd.match.i2c.address = pcdev->pdata->sensor_i2c_address;
2314 err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev, &pcdev->asd);
2321 if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
2328 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
2330 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8)
2331 pcdev->width_flags = 1 << 7;
2332 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9)
2333 pcdev->width_flags |= 1 << 8;
2334 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10)
2335 pcdev->width_flags |= 1 << 9;
2336 if (!pcdev->mclk) {
2339 pcdev->mclk = 20000000;
2342 pcdev->mclk_divisor = mclk_get_divisor(pdev, pcdev);
2344 INIT_LIST_HEAD(&pcdev->capture);
2345 spin_lock_init(&pcdev->lock);
2346 mutex_init(&pcdev->mlock);
2355 pcdev->irq = irq;
2356 pcdev->base = base;
2359 pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y");
2360 if (IS_ERR(pcdev->dma_chans[0])) {
2362 return PTR_ERR(pcdev->dma_chans[0]);
2365 pcdev->dma_chans[1] = dma_request_chan(&pdev->dev, "CI_U");
2366 if (IS_ERR(pcdev->dma_chans[1])) {
2368 err = PTR_ERR(pcdev->dma_chans[1]);
2372 pcdev->dma_chans[2] = dma_request_chan(&pdev->dev, "CI_V");
2373 if (IS_ERR(pcdev->dma_chans[2])) {
2375 err = PTR_ERR(pcdev->dma_chans[2]);
2380 config.src_addr = pcdev->res->start + CIBR0 + i * 8;
2381 err = dmaengine_slave_config(pcdev->dma_chans[i], &config);
2390 err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
2391 PXA_CAM_DRV_NAME, pcdev);
2397 tasklet_setup(&pcdev->task_eof, pxa_camera_eof);
2399 pxa_camera_activate(pcdev);
2401 dev_set_drvdata(&pdev->dev, pcdev);
2402 err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev);
2406 v4l2_async_notifier_init(&pcdev->notifier);
2408 err = v4l2_async_notifier_add_subdev(&pcdev->notifier, &pcdev->asd);
2410 fwnode_handle_put(pcdev->asd.match.fwnode);
2414 pcdev->notifier.ops = &pxa_camera_sensor_ops;
2417 pcdev->asd.match_type = V4L2_ASYNC_MATCH_I2C;
2419 err = pxa_camera_init_videobuf2(pcdev);
2424 pcdev->asd.match.i2c.adapter_id,
2425 pcdev->asd.match.i2c.address);
2427 pcdev->mclk_clk = v4l2_clk_register(&pxa_camera_mclk_ops, clk_name, NULL);
2428 if (IS_ERR(pcdev->mclk_clk)) {
2429 err = PTR_ERR(pcdev->mclk_clk);
2433 err = v4l2_async_notifier_register(&pcdev->v4l2_dev, &pcdev->notifier);
2439 v4l2_clk_unregister(pcdev->mclk_clk);
2441 v4l2_async_notifier_cleanup(&pcdev->notifier);
2443 v4l2_device_unregister(&pcdev->v4l2_dev);
2445 pxa_camera_deactivate(pcdev);
2446 tasklet_kill(&pcdev->task_eof);
2448 dma_release_channel(pcdev->dma_chans[2]);
2450 dma_release_channel(pcdev->dma_chans[1]);
2452 dma_release_channel(pcdev->dma_chans[0]);
2458 struct pxa_camera_dev *pcdev = dev_get_drvdata(&pdev->dev);
2460 pxa_camera_deactivate(pcdev);
2461 tasklet_kill(&pcdev->task_eof);
2462 dma_release_channel(pcdev->dma_chans[0]);
2463 dma_release_channel(pcdev->dma_chans[1]);
2464 dma_release_channel(pcdev->dma_chans[2]);
2466 v4l2_async_notifier_unregister(&pcdev->notifier);
2467 v4l2_async_notifier_cleanup(&pcdev->notifier);
2469 if (pcdev->mclk_clk) {
2470 v4l2_clk_unregister(pcdev->mclk_clk);
2471 pcdev->mclk_clk = NULL;
2474 v4l2_device_unregister(&pcdev->v4l2_dev);