7

Who is responsible for creating the "/sys/class/drm" directory structure, more specifically the "/sys/class/drm/card0-LVDS-1" directory?

I am using kernel-2.6.38 and an nVidia card.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
SHW
  • 14,454
  • 14
  • 63
  • 101

2 Answers2

4

The DRM module is responsible for that subtree in SysFS. You can browse the source code for that in drivers/gpu/drm/drm_sysfs.c.

The subdirectories are per-connector, with a name of the form card%d-%s with %d replaced by an index (that I know nothing about) and %s replaced with the connector name.

Five files per device should show up:

  • Connection status
  • Enabled (or not)
  • DPMS state
  • Mode list
  • EDID

For some devices, you'll get extra information for sub-connectors too.

Mat
  • 51,578
  • 10
  • 158
  • 140
  • I inserted the "drm" module, but I get the blank directory. – SHW Mar 30 '12 at 13:29
  • Yes, and? If you're using the proprietary nVidia driver, I don't believe it uses/supports (whatever the right term is) DRM. Not sure if the nouveau driver does. – Mat Mar 30 '12 at 13:31
  • I need this directory structure for another purpose. but to use it, I had to make it's presence on system. – SHW Mar 30 '12 at 13:34
  • If your driver doesn't use/support DRM, you won't get it. – Mat Mar 30 '12 at 13:35
  • My final intention is http://unix.stackexchange.com/questions/7622/edid-information – SHW Mar 30 '12 at 13:38
  • 2
    That doesn't change the fact that if your card's driver doesn't talk to the Linux DRM subsystem, _you won't get that directory_. – Mat Mar 30 '12 at 13:39
0

There has been some development since the last accepted answer, hence I'm creating a new answer.

As of v6.2.11 the source code responsible for this sysfs subtree is still drivers/gpu/drm/drm_sysfs.c (working link).

The DRM driver itself may create 5 different entry types, based on hardware support. They are: card%d, controlD%s, renderD%d, accel%d, then for each card connector card%d-%s. The %d are device minor numbers, which should start at 0 for the cards then in matching 64 increments for controlD, renderD and accel respectively. There are no minors for the connectors, they are on their respective card's minor.

The controlD entries are backward-compatibility symlinks created by create_compat_control_link() in drivers/gpu/drm/drm_drv.c.

The connector name's format (the %s in card%d-%s) is %s-%d, where %s is a name from struct drm_conn_prop_enum_list drm_connector_enum_list[] in drivers/gpu/drm/drm_connector.c and %d is a connector index number starting from 1 (as a card may have more than one connector of the same type).

Finally, any driver can register its own devices here using drm_class_device_register() in drivers/gpu/drm/drm_sysfs.c.