Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 1/*
 2 * Copyright (C) 2013 NVIDIA Corporation
 3 *
 4 * This program is free software; you can redistribute it and/or modify
 5 * it under the terms of the GNU General Public License version 2 as
 6 * published by the Free Software Foundation.
 7 */
 8
 9#include "drm.h"
10
11static int drm_host1x_set_busid(struct drm_device *dev,
12				struct drm_master *master)
13{
14	const char *device = dev_name(dev->dev);
15	const char *driver = dev->driver->name;
16	const char *bus = dev->dev->bus->name;
17	int length;
18
19	master->unique_len = strlen(bus) + 1 + strlen(device);
20	master->unique_size = master->unique_len;
21
22	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
23	if (!master->unique)
24		return -ENOMEM;
25
26	snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
27
28	length = strlen(driver) + 1 + master->unique_len;
29
30	dev->devname = kmalloc(length + 1, GFP_KERNEL);
31	if (!dev->devname)
32		return -ENOMEM;
33
34	snprintf(dev->devname, length + 1, "%s@%s", driver, master->unique);
35
36	return 0;
37}
38
39static struct drm_bus drm_host1x_bus = {
40	.bus_type = DRIVER_BUS_HOST1X,
41	.set_busid = drm_host1x_set_busid,
42};
43
44int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
45{
46	struct drm_device *drm;
47	int ret;
48
49	driver->bus = &drm_host1x_bus;
50
51	drm = drm_dev_alloc(driver, &device->dev);
52	if (!drm)
53		return -ENOMEM;
54
55	ret = drm_dev_register(drm, 0);
56	if (ret)
57		goto err_free;
58
59	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
60		 driver->major, driver->minor, driver->patchlevel,
61		 driver->date, drm->primary->index);
62
63	return 0;
64
65err_free:
66	drm_dev_unref(drm);
67	return ret;
68}
69
70void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device)
71{
72	struct tegra_drm *tegra = dev_get_drvdata(&device->dev);
73
74	drm_put_dev(tegra->drm);
75}