15 #include <linux/device.h>
16 #include <linux/kdev_t.h>
19 #include <linux/export.h>
25 #define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
26 #define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
28 static struct device_type drm_sysfs_device_minor = {
42 if (dev->
type == &drm_sysfs_device_minor) {
46 if (drm_minor->type == DRM_MINOR_LEGACY &&
47 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
48 drm_dev->driver->suspend)
49 return drm_dev->driver->suspend(drm_dev, state);
61 static int drm_class_resume(
struct device *dev)
63 if (dev->
type == &drm_sysfs_device_minor) {
67 if (drm_minor->type == DRM_MINOR_LEGACY &&
68 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
69 drm_dev->driver->resume)
70 return drm_dev->driver->resume(drm_dev);
105 err = PTR_ERR(
class);
109 class->suspend = drm_class_suspend;
110 class->resume = drm_class_resume;
116 class->devnode = drm_devnode;
148 static void drm_sysfs_device_release(
struct device *dev)
169 status = connector->
funcs->detect(connector,
true);
176 static ssize_t dpms_show(
struct device *device,
186 dev->mode_config.dpms_property,
195 static ssize_t enabled_show(
struct device *device,
209 struct device *connector_dev =
container_of(kobj,
struct device, kobj);
225 if (off + count > size)
227 memcpy(buf, edid + off, count);
232 static ssize_t modes_show(
struct device *device,
248 static ssize_t subconnector_show(
struct device *device,
261 prop = dev->mode_config.dvi_i_subconnector_property;
267 prop = dev->mode_config.tv_subconnector_property;
271 DRM_ERROR(
"Wrong connector type for this property\n");
276 DRM_ERROR(
"Unable to find subconnector property\n");
289 static ssize_t select_subconnector_show(
struct device *device,
302 prop = dev->mode_config.dvi_i_select_subconnector_property;
308 prop = dev->mode_config.tv_select_subconnector_property;
312 DRM_ERROR(
"Wrong connector type for this property\n");
317 DRM_ERROR(
"Unable to find select subconnector property\n");
373 BUG_ON(device_is_registered(&connector->
kdev));
375 connector->
kdev.parent = &dev->primary->kdev;
377 connector->
kdev.release = drm_sysfs_device_release;
379 DRM_DEBUG(
"adding \"%s\" to sysfs\n",
387 DRM_ERROR(
"failed to register connector device: %d\n", ret);
393 for (attr_cnt = 0; attr_cnt <
ARRAY_SIZE(connector_attrs); attr_cnt++) {
410 for (opt_cnt = 0; opt_cnt <
ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) {
430 for (i = 0; i < opt_cnt; i++)
432 for (i = 0; i < attr_cnt; i++)
458 if (!connector->
kdev.parent)
460 DRM_DEBUG(
"removing \"%s\" from sysfs\n",
463 for (i = 0; i <
ARRAY_SIZE(connector_attrs); i++)
481 char *event_string =
"HOTPLUG=1";
482 char *envp[] = { event_string,
NULL };
484 DRM_DEBUG(
"generating hotplug event\n");
504 minor->kdev.parent = minor->dev->dev;
507 minor->kdev.release = drm_sysfs_device_release;
508 minor->kdev.devt = minor->device;
509 minor->kdev.type = &drm_sysfs_device_minor;
510 if (minor->type == DRM_MINOR_CONTROL)
511 minor_str =
"controlD%d";
512 else if (minor->type == DRM_MINOR_RENDER)
513 minor_str =
"renderD%d";
515 minor_str =
"card%d";
521 DRM_ERROR(
"device add failed: %d\n", err);
540 if (minor->kdev.parent)
542 minor->kdev.parent =
NULL;