aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/v4l2-mc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-mc.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-mc.c76
1 files changed, 1 insertions, 75 deletions
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 64eefb9ffb7e..4a1efa827fe2 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Media Controller ancillary functions 2 * Media Controller ancillary functions
3 * 3 *
4 * (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com> 4 * Copyright (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -15,83 +15,9 @@
15 */ 15 */
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/pci.h>
19#include <linux/usb.h>
20#include <media/media-entity.h> 18#include <media/media-entity.h>
21#include <media/v4l2-mc.h> 19#include <media/v4l2-mc.h>
22 20
23
24struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
25 const char *name)
26{
27#ifdef CONFIG_PCI
28 struct media_device *mdev;
29
30 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
31 if (!mdev)
32 return NULL;
33
34 mdev->dev = &pci_dev->dev;
35
36 if (name)
37 strlcpy(mdev->model, name, sizeof(mdev->model));
38 else
39 strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model));
40
41 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev));
42
43 mdev->hw_revision = (pci_dev->subsystem_vendor << 16)
44 | pci_dev->subsystem_device;
45
46 mdev->driver_version = LINUX_VERSION_CODE;
47
48 media_device_init(mdev);
49
50 return mdev;
51#else
52 return NULL;
53#endif
54}
55EXPORT_SYMBOL_GPL(v4l2_mc_pci_media_device_init);
56
57struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
58 const char *board_name,
59 const char *driver_name)
60{
61#ifdef CONFIG_USB
62 struct media_device *mdev;
63
64 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
65 if (!mdev)
66 return NULL;
67
68 mdev->dev = &udev->dev;
69
70 if (driver_name)
71 strlcpy(mdev->driver_name, driver_name,
72 sizeof(mdev->driver_name));
73
74 if (board_name)
75 strlcpy(mdev->model, board_name, sizeof(mdev->model));
76 else if (udev->product)
77 strlcpy(mdev->model, udev->product, sizeof(mdev->model));
78 else
79 strlcpy(mdev->model, "unknown model", sizeof(mdev->model));
80 if (udev->serial)
81 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
82 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
83 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
84 mdev->driver_version = LINUX_VERSION_CODE;
85
86 media_device_init(mdev);
87
88 return mdev;
89#else
90 return NULL;
91#endif
92}
93EXPORT_SYMBOL_GPL(__v4l2_mc_usb_media_device_init);
94
95int v4l2_mc_create_media_graph(struct media_device *mdev) 21int v4l2_mc_create_media_graph(struct media_device *mdev)
96 22
97{ 23{