linux-4.4.1/skeleton_probe()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#gf7bd568]
#backlinks
*説明 [#h68659ff]
-パス: [[linux-4.4.1/Documentation/video4linux/v4l2-pci-s...
-FIXME: これは何?
--説明
**引数 [#hf421675]
-struct pci_dev *pdev
--
--[[linux-4.4.1/pci_dev]]
-const struct pci_device_id *ent
--
--[[linux-4.4.1/pci_device_id]]
**返り値 [#j9a77352]
-int
--
**参考 [#h306515e]
*実装 [#lab6d678]
/*
* The initial setup of this device instance. Note that ...
* the driver should be complete. So the initial format,...
* and video input should all be initialized to some rea...
*/
static int skeleton_probe(struct pci_dev *pdev, const st...
{
/* The initial timings are chosen to be 720p60. */
static const struct v4l2_dv_timings timings_def =
V4L2_DV_BT_CEA_1280X720P60;
struct skeleton *skel;
struct video_device *vdev;
struct v4l2_ctrl_handler *hdl;
struct vb2_queue *q;
int ret;
-
--[[linux-4.4.1/v4l2_dv_timings]]
--[[linux-4.4.1/skeleton]]
--[[linux-4.4.1/video_device]]
--[[linux-4.4.1/v4l2_ctrl_handler]]
--[[linux-4.4.1/vb2_queue]]
/* Enable PCI */
ret = pci_enable_device(pdev);
if (ret)
return ret;
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "no suitable DMA ava...
goto disable_pci;
}
-
--[[linux-4.4.1/pci_enable_device()]]
--[[linux-4.4.1/pci_set_dma_mask()]]
--[[linux-4.4.1/DMA_BIT_MASK()]]
--[[linux-4.4.1/dev_err()]]
/* Allocate a new instance */
skel = devm_kzalloc(&pdev->dev, sizeof(struct sk...
if (!skel)
return -ENOMEM;
-
--[[linux-4.4.1/devm_kzalloc()]]
/* Allocate the interrupt */
ret = devm_request_irq(&pdev->dev, pdev->irq,
skeleton_irq, 0, KBUILD_M...
if (ret) {
dev_err(&pdev->dev, "request_irq failed\...
goto disable_pci;
}
skel->pdev = pdev;
-
--[[linux-4.4.1/devm_request_irq()]]
--[[linux-4.4.1/skeleton_irq()]]
/* Fill in the initial format-related settings */
skel->timings = timings_def;
skel->std = V4L2_STD_625_50;
skeleton_fill_pix_format(skel, &skel->format);
-
--[[linux-4.4.1/skeleton_fill_pix_format()]]
/* Initialize the top-level structure */
ret = v4l2_device_register(&pdev->dev, &skel->v4...
if (ret)
goto disable_pci;
-
--[[linux-4.4.1/v4l2_device_register()]]
mutex_init(&skel->lock);
-
--[[linux-4.4.1/mutex_init()]]
/* Add the controls */
hdl = &skel->ctrl_handler;
v4l2_ctrl_handler_init(hdl, 4);
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_BRIGHTNESS, 0, 255, 1...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_CONTRAST, 0, 255, 1, ...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_SATURATION, 0, 255, 1...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_HUE, -128, 127, 1, 0);
if (hdl->error) {
ret = hdl->error;
goto free_hdl;
}
skel->v4l2_dev.ctrl_handler = hdl;
-
--[[linux-4.4.1/v4l2_ctrl_handler_init()]]
--[[linux-4.4.1/v4l2_ctrl_new_std()]]
--[[linux-4.4.1/skel_ctrl_ops(global)]]
/* Initialize the vb2 queue */
q = &skel->queue;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
q->drv_priv = skel;
q->buf_struct_size = sizeof(struct skel_buffer);
q->ops = &skel_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MON...
-
--[[linux-4.4.1/skel_qops(global)]]
--[[linux-4.4.1/vb2_dma_contig_memops(global)]]
/*
* Assume that this DMA engine needs to have at ...
* available before it can be started. The start...
* won't be called until at least this many buff...
*/
q->min_buffers_needed = 2;
/*
* The serialization lock for the streaming ioct...
* as the main serialization lock, but if some o...
* ioctls could take a long time to execute, the...
* have a different lock here to prevent VIDIOC_...
* blocked while waiting for another action to f...
* generally not needed for PCI devices, but USB...
* want a separate lock here.
*/
q->lock = &skel->lock;
/*
* Since this driver can only do 32-bit DMA we m...
* the vb2 core will allocate the buffers in 32-...
*/
q->gfp_flags = GFP_DMA32;
ret = vb2_queue_init(q);
if (ret)
goto free_hdl;
-
--[[linux-4.4.1/vb2_queue_init()]]
skel->alloc_ctx = vb2_dma_contig_init_ctx(&pdev-...
if (IS_ERR(skel->alloc_ctx)) {
dev_err(&pdev->dev, "Can't allocate buff...
ret = PTR_ERR(skel->alloc_ctx);
goto free_hdl;
}
INIT_LIST_HEAD(&skel->buf_list);
spin_lock_init(&skel->qlock);
-
--[[linux-4.4.1/vb2_dma_contig_init_ctx()]]
--[[linux-4.4.1/IS_ERR()]]
--[[linux-4.4.1/dev_err()]]
--[[linux-4.4.1/PTR_ERR()]]
--[[linux-4.4.1/INIT_LIST_HEAD()]]
--[[linux-4.4.1/spin_lock_init()]]
/* Initialize the video_device structure */
vdev = &skel->vdev;
strlcpy(vdev->name, KBUILD_MODNAME, sizeof(vdev-...
-
--[[linux-4.4.1/strlcpy()]]
/*
* There is nothing to clean up, so release is s...
* function. The release callback must be non-NU...
*/
vdev->release = video_device_release_empty;
vdev->fops = &skel_fops,
vdev->ioctl_ops = &skel_ioctl_ops,
-
--[[linux-4.4.1/video_device_release_empty()]]
--[[linux-4.4.1/skel_fops(global)]]
--[[linux-4.4.1/skel_ioctl_ops(global)]]
/*
* The main serialization lock. All ioctls are s...
* lock. Exception: if q->lock is set, then the ...
* are serialized by that separate lock.
*/
vdev->lock = &skel->lock;
vdev->queue = q;
vdev->v4l2_dev = &skel->v4l2_dev;
/* Supported SDTV standards, if any */
vdev->tvnorms = SKEL_TVNORMS;
video_set_drvdata(vdev, skel);
-
--[[linux-4.4.1/video_set_drvdata()]]
ret = video_register_device(vdev, VFL_TYPE_GRABB...
if (ret)
goto free_ctx;
-
--[[linux-4.4.1/video_register_device()]]
dev_info(&pdev->dev, "V4L2 PCI Skeleton Driver l...
return 0;
-
--[[linux-4.4.1/dev_info()]]
free_ctx:
vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
-
--[[linux-4.4.1/vb2_dma_contig_cleanup_ctx()]]
free_hdl:
v4l2_ctrl_handler_free(&skel->ctrl_handler);
v4l2_device_unregister(&skel->v4l2_dev);
-
--[[linux-4.4.1/v4l2_ctrl_handler_free()]]
--[[linux-4.4.1/v4l2_device_unregister()]]
disable_pci:
pci_disable_device(pdev);
-
--[[linux-4.4.1/pci_disable_device()]]
return ret;
}
*コメント [#s051519a]
終了行:
*参照元 [#gf7bd568]
#backlinks
*説明 [#h68659ff]
-パス: [[linux-4.4.1/Documentation/video4linux/v4l2-pci-s...
-FIXME: これは何?
--説明
**引数 [#hf421675]
-struct pci_dev *pdev
--
--[[linux-4.4.1/pci_dev]]
-const struct pci_device_id *ent
--
--[[linux-4.4.1/pci_device_id]]
**返り値 [#j9a77352]
-int
--
**参考 [#h306515e]
*実装 [#lab6d678]
/*
* The initial setup of this device instance. Note that ...
* the driver should be complete. So the initial format,...
* and video input should all be initialized to some rea...
*/
static int skeleton_probe(struct pci_dev *pdev, const st...
{
/* The initial timings are chosen to be 720p60. */
static const struct v4l2_dv_timings timings_def =
V4L2_DV_BT_CEA_1280X720P60;
struct skeleton *skel;
struct video_device *vdev;
struct v4l2_ctrl_handler *hdl;
struct vb2_queue *q;
int ret;
-
--[[linux-4.4.1/v4l2_dv_timings]]
--[[linux-4.4.1/skeleton]]
--[[linux-4.4.1/video_device]]
--[[linux-4.4.1/v4l2_ctrl_handler]]
--[[linux-4.4.1/vb2_queue]]
/* Enable PCI */
ret = pci_enable_device(pdev);
if (ret)
return ret;
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "no suitable DMA ava...
goto disable_pci;
}
-
--[[linux-4.4.1/pci_enable_device()]]
--[[linux-4.4.1/pci_set_dma_mask()]]
--[[linux-4.4.1/DMA_BIT_MASK()]]
--[[linux-4.4.1/dev_err()]]
/* Allocate a new instance */
skel = devm_kzalloc(&pdev->dev, sizeof(struct sk...
if (!skel)
return -ENOMEM;
-
--[[linux-4.4.1/devm_kzalloc()]]
/* Allocate the interrupt */
ret = devm_request_irq(&pdev->dev, pdev->irq,
skeleton_irq, 0, KBUILD_M...
if (ret) {
dev_err(&pdev->dev, "request_irq failed\...
goto disable_pci;
}
skel->pdev = pdev;
-
--[[linux-4.4.1/devm_request_irq()]]
--[[linux-4.4.1/skeleton_irq()]]
/* Fill in the initial format-related settings */
skel->timings = timings_def;
skel->std = V4L2_STD_625_50;
skeleton_fill_pix_format(skel, &skel->format);
-
--[[linux-4.4.1/skeleton_fill_pix_format()]]
/* Initialize the top-level structure */
ret = v4l2_device_register(&pdev->dev, &skel->v4...
if (ret)
goto disable_pci;
-
--[[linux-4.4.1/v4l2_device_register()]]
mutex_init(&skel->lock);
-
--[[linux-4.4.1/mutex_init()]]
/* Add the controls */
hdl = &skel->ctrl_handler;
v4l2_ctrl_handler_init(hdl, 4);
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_BRIGHTNESS, 0, 255, 1...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_CONTRAST, 0, 255, 1, ...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_SATURATION, 0, 255, 1...
v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
V4L2_CID_HUE, -128, 127, 1, 0);
if (hdl->error) {
ret = hdl->error;
goto free_hdl;
}
skel->v4l2_dev.ctrl_handler = hdl;
-
--[[linux-4.4.1/v4l2_ctrl_handler_init()]]
--[[linux-4.4.1/v4l2_ctrl_new_std()]]
--[[linux-4.4.1/skel_ctrl_ops(global)]]
/* Initialize the vb2 queue */
q = &skel->queue;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
q->drv_priv = skel;
q->buf_struct_size = sizeof(struct skel_buffer);
q->ops = &skel_qops;
q->mem_ops = &vb2_dma_contig_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MON...
-
--[[linux-4.4.1/skel_qops(global)]]
--[[linux-4.4.1/vb2_dma_contig_memops(global)]]
/*
* Assume that this DMA engine needs to have at ...
* available before it can be started. The start...
* won't be called until at least this many buff...
*/
q->min_buffers_needed = 2;
/*
* The serialization lock for the streaming ioct...
* as the main serialization lock, but if some o...
* ioctls could take a long time to execute, the...
* have a different lock here to prevent VIDIOC_...
* blocked while waiting for another action to f...
* generally not needed for PCI devices, but USB...
* want a separate lock here.
*/
q->lock = &skel->lock;
/*
* Since this driver can only do 32-bit DMA we m...
* the vb2 core will allocate the buffers in 32-...
*/
q->gfp_flags = GFP_DMA32;
ret = vb2_queue_init(q);
if (ret)
goto free_hdl;
-
--[[linux-4.4.1/vb2_queue_init()]]
skel->alloc_ctx = vb2_dma_contig_init_ctx(&pdev-...
if (IS_ERR(skel->alloc_ctx)) {
dev_err(&pdev->dev, "Can't allocate buff...
ret = PTR_ERR(skel->alloc_ctx);
goto free_hdl;
}
INIT_LIST_HEAD(&skel->buf_list);
spin_lock_init(&skel->qlock);
-
--[[linux-4.4.1/vb2_dma_contig_init_ctx()]]
--[[linux-4.4.1/IS_ERR()]]
--[[linux-4.4.1/dev_err()]]
--[[linux-4.4.1/PTR_ERR()]]
--[[linux-4.4.1/INIT_LIST_HEAD()]]
--[[linux-4.4.1/spin_lock_init()]]
/* Initialize the video_device structure */
vdev = &skel->vdev;
strlcpy(vdev->name, KBUILD_MODNAME, sizeof(vdev-...
-
--[[linux-4.4.1/strlcpy()]]
/*
* There is nothing to clean up, so release is s...
* function. The release callback must be non-NU...
*/
vdev->release = video_device_release_empty;
vdev->fops = &skel_fops,
vdev->ioctl_ops = &skel_ioctl_ops,
-
--[[linux-4.4.1/video_device_release_empty()]]
--[[linux-4.4.1/skel_fops(global)]]
--[[linux-4.4.1/skel_ioctl_ops(global)]]
/*
* The main serialization lock. All ioctls are s...
* lock. Exception: if q->lock is set, then the ...
* are serialized by that separate lock.
*/
vdev->lock = &skel->lock;
vdev->queue = q;
vdev->v4l2_dev = &skel->v4l2_dev;
/* Supported SDTV standards, if any */
vdev->tvnorms = SKEL_TVNORMS;
video_set_drvdata(vdev, skel);
-
--[[linux-4.4.1/video_set_drvdata()]]
ret = video_register_device(vdev, VFL_TYPE_GRABB...
if (ret)
goto free_ctx;
-
--[[linux-4.4.1/video_register_device()]]
dev_info(&pdev->dev, "V4L2 PCI Skeleton Driver l...
return 0;
-
--[[linux-4.4.1/dev_info()]]
free_ctx:
vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
-
--[[linux-4.4.1/vb2_dma_contig_cleanup_ctx()]]
free_hdl:
v4l2_ctrl_handler_free(&skel->ctrl_handler);
v4l2_device_unregister(&skel->v4l2_dev);
-
--[[linux-4.4.1/v4l2_ctrl_handler_free()]]
--[[linux-4.4.1/v4l2_device_unregister()]]
disable_pci:
pci_disable_device(pdev);
-
--[[linux-4.4.1/pci_disable_device()]]
return ret;
}
*コメント [#s051519a]
ページ名: