dt3155.c (9938b04472d5c59f8bd8152a548533a8599596a2) | dt3155.c (2bc46b3ad3c15165f91459b07ff8682478683194) |
---|---|
1/*************************************************************************** 2 * Copyright (C) 2006-2010 by Marin Mitov * 3 * mitov@issp.bas.bg * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * --- 127 unchanged lines hidden (view full) --- 136 unsigned int sizes[], void *alloc_ctxs[]) 137 138{ 139 struct dt3155_priv *pd = vb2_get_drv_priv(vq); 140 unsigned size = pd->width * pd->height; 141 142 if (vq->num_buffers + *nbuffers < 2) 143 *nbuffers = 2 - vq->num_buffers; | 1/*************************************************************************** 2 * Copyright (C) 2006-2010 by Marin Mitov * 3 * mitov@issp.bas.bg * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * --- 127 unchanged lines hidden (view full) --- 136 unsigned int sizes[], void *alloc_ctxs[]) 137 138{ 139 struct dt3155_priv *pd = vb2_get_drv_priv(vq); 140 unsigned size = pd->width * pd->height; 141 142 if (vq->num_buffers + *nbuffers < 2) 143 *nbuffers = 2 - vq->num_buffers; |
144 alloc_ctxs[0] = pd->alloc_ctx; | |
145 if (*num_planes) 146 return sizes[0] < size ? -EINVAL : 0; 147 *num_planes = 1; 148 sizes[0] = size; 149 return 0; 150} 151 152static int dt3155_buf_prepare(struct vb2_buffer *vb) --- 386 unchanged lines hidden (view full) --- 539 pd->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 540 pd->vidq.io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ; 541 pd->vidq.ops = &q_ops; 542 pd->vidq.mem_ops = &vb2_dma_contig_memops; 543 pd->vidq.drv_priv = pd; 544 pd->vidq.min_buffers_needed = 2; 545 pd->vidq.gfp_flags = GFP_DMA32; 546 pd->vidq.lock = &pd->mux; /* for locking v4l2_file_operations */ | 144 if (*num_planes) 145 return sizes[0] < size ? -EINVAL : 0; 146 *num_planes = 1; 147 sizes[0] = size; 148 return 0; 149} 150 151static int dt3155_buf_prepare(struct vb2_buffer *vb) --- 386 unchanged lines hidden (view full) --- 538 pd->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 539 pd->vidq.io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ; 540 pd->vidq.ops = &q_ops; 541 pd->vidq.mem_ops = &vb2_dma_contig_memops; 542 pd->vidq.drv_priv = pd; 543 pd->vidq.min_buffers_needed = 2; 544 pd->vidq.gfp_flags = GFP_DMA32; 545 pd->vidq.lock = &pd->mux; /* for locking v4l2_file_operations */ |
546 pd->vidq.dev = &pdev->dev; |
|
547 pd->vdev.queue = &pd->vidq; 548 err = vb2_queue_init(&pd->vidq); 549 if (err < 0) 550 goto err_v4l2_dev_unreg; | 547 pd->vdev.queue = &pd->vidq; 548 err = vb2_queue_init(&pd->vidq); 549 if (err < 0) 550 goto err_v4l2_dev_unreg; |
551 pd->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 552 if (IS_ERR(pd->alloc_ctx)) { 553 dev_err(&pdev->dev, "Can't allocate buffer context"); 554 err = PTR_ERR(pd->alloc_ctx); 555 goto err_v4l2_dev_unreg; 556 } | |
557 spin_lock_init(&pd->lock); 558 pd->config = ACQ_MODE_EVEN; 559 err = pci_enable_device(pdev); 560 if (err) | 551 spin_lock_init(&pd->lock); 552 pd->config = ACQ_MODE_EVEN; 553 err = pci_enable_device(pdev); 554 if (err) |
561 goto err_free_ctx; | 555 goto err_v4l2_dev_unreg; |
562 err = pci_request_region(pdev, 0, pci_name(pdev)); 563 if (err) 564 goto err_pci_disable; 565 pd->regs = pci_iomap(pdev, 0, pci_resource_len(pd->pdev, 0)); 566 if (!pd->regs) { 567 err = -ENOMEM; 568 goto err_free_reg; 569 } --- 13 unchanged lines hidden (view full) --- 583err_free_irq: 584 free_irq(pd->pdev->irq, pd); 585err_iounmap: 586 pci_iounmap(pdev, pd->regs); 587err_free_reg: 588 pci_release_region(pdev, 0); 589err_pci_disable: 590 pci_disable_device(pdev); | 556 err = pci_request_region(pdev, 0, pci_name(pdev)); 557 if (err) 558 goto err_pci_disable; 559 pd->regs = pci_iomap(pdev, 0, pci_resource_len(pd->pdev, 0)); 560 if (!pd->regs) { 561 err = -ENOMEM; 562 goto err_free_reg; 563 } --- 13 unchanged lines hidden (view full) --- 577err_free_irq: 578 free_irq(pd->pdev->irq, pd); 579err_iounmap: 580 pci_iounmap(pdev, pd->regs); 581err_free_reg: 582 pci_release_region(pdev, 0); 583err_pci_disable: 584 pci_disable_device(pdev); |
591err_free_ctx: 592 vb2_dma_contig_cleanup_ctx(pd->alloc_ctx); | |
593err_v4l2_dev_unreg: 594 v4l2_device_unregister(&pd->v4l2_dev); 595 return err; 596} 597 598static void dt3155_remove(struct pci_dev *pdev) 599{ 600 struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev); 601 struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, 602 v4l2_dev); 603 604 video_unregister_device(&pd->vdev); 605 free_irq(pd->pdev->irq, pd); 606 vb2_queue_release(&pd->vidq); 607 v4l2_device_unregister(&pd->v4l2_dev); 608 pci_iounmap(pdev, pd->regs); 609 pci_release_region(pdev, 0); 610 pci_disable_device(pdev); | 585err_v4l2_dev_unreg: 586 v4l2_device_unregister(&pd->v4l2_dev); 587 return err; 588} 589 590static void dt3155_remove(struct pci_dev *pdev) 591{ 592 struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev); 593 struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, 594 v4l2_dev); 595 596 video_unregister_device(&pd->vdev); 597 free_irq(pd->pdev->irq, pd); 598 vb2_queue_release(&pd->vidq); 599 v4l2_device_unregister(&pd->v4l2_dev); 600 pci_iounmap(pdev, pd->regs); 601 pci_release_region(pdev, 0); 602 pci_disable_device(pdev); |
611 vb2_dma_contig_cleanup_ctx(pd->alloc_ctx); | |
612} 613 614static const struct pci_device_id pci_ids[] = { 615 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, DT3155_DEVICE_ID) }, 616 { 0, /* zero marks the end */ }, 617}; 618MODULE_DEVICE_TABLE(pci, pci_ids); 619 --- 13 unchanged lines hidden --- | 603} 604 605static const struct pci_device_id pci_ids[] = { 606 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, DT3155_DEVICE_ID) }, 607 { 0, /* zero marks the end */ }, 608}; 609MODULE_DEVICE_TABLE(pci, pci_ids); 610 --- 13 unchanged lines hidden --- |