bus.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "drm.h"
  9. static int drm_host1x_set_busid(struct drm_device *dev,
  10. struct drm_master *master)
  11. {
  12. const char *device = dev_name(dev->dev);
  13. const char *bus = dev->dev->bus->name;
  14. master->unique_len = strlen(bus) + 1 + strlen(device);
  15. master->unique_size = master->unique_len;
  16. master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
  17. if (!master->unique)
  18. return -ENOMEM;
  19. snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
  20. return 0;
  21. }
  22. static struct drm_bus drm_host1x_bus = {
  23. .set_busid = drm_host1x_set_busid,
  24. };
  25. int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
  26. {
  27. struct drm_device *drm;
  28. int ret;
  29. driver->bus = &drm_host1x_bus;
  30. drm = drm_dev_alloc(driver, &device->dev);
  31. if (!drm)
  32. return -ENOMEM;
  33. ret = drm_dev_register(drm, 0);
  34. if (ret)
  35. goto err_free;
  36. DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
  37. driver->major, driver->minor, driver->patchlevel,
  38. driver->date, drm->primary->index);
  39. return 0;
  40. err_free:
  41. drm_dev_unref(drm);
  42. return ret;
  43. }
  44. void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device)
  45. {
  46. struct tegra_drm *tegra = dev_get_drvdata(&device->dev);
  47. drm_put_dev(tegra->drm);
  48. }