1 /* 2 * Created: Sun Dec 21 13:08:50 2008 by bgamari@gmail.com 3 * 4 * Copyright 2008 Ben Gamari <bgamari@gmail.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 #include <linux/debugfs.h> 27 #include <linux/export.h> 28 #include <linux/seq_file.h> 29 #include <linux/slab.h> 30 #include <linux/uaccess.h> 31 32 #include <drm/drm_atomic.h> 33 #include <drm/drm_auth.h> 34 #include <drm/drm_bridge.h> 35 #include <drm/drm_debugfs.h> 36 #include <drm/drm_device.h> 37 #include <drm/drm_drv.h> 38 #include <drm/drm_edid.h> 39 #include <drm/drm_file.h> 40 #include <drm/drm_gem.h> 41 #include <drm/drm_managed.h> 42 #include <drm/drm_gpuvm.h> 43 44 #include "drm_crtc_internal.h" 45 #include "drm_internal.h" 46 47 /*************************************************** 48 * Initialization, etc. 49 **************************************************/ 50 51 static int drm_name_info(struct seq_file *m, void *data) 52 { 53 struct drm_debugfs_entry *entry = m->private; 54 struct drm_device *dev = entry->dev; 55 struct drm_master *master; 56 57 mutex_lock(&dev->master_mutex); 58 master = dev->master; 59 seq_printf(m, "%s", dev->driver->name); 60 if (dev->dev) 61 seq_printf(m, " dev=%s", dev_name(dev->dev)); 62 if (master && master->unique) 63 seq_printf(m, " master=%s", master->unique); 64 if (dev->unique) 65 seq_printf(m, " unique=%s", dev->unique); 66 seq_printf(m, "\n"); 67 mutex_unlock(&dev->master_mutex); 68 69 return 0; 70 } 71 72 static int drm_clients_info(struct seq_file *m, void *data) 73 { 74 struct drm_debugfs_entry *entry = m->private; 75 struct drm_device *dev = entry->dev; 76 struct drm_file *priv; 77 kuid_t uid; 78 79 seq_printf(m, 80 "%20s %5s %3s master a %5s %10s %*s %20s\n", 81 "command", 82 "tgid", 83 "dev", 84 "uid", 85 "magic", 86 DRM_CLIENT_NAME_MAX_LEN, 87 "name", 88 "id"); 89 90 /* dev->filelist is sorted youngest first, but we want to present 91 * oldest first (i.e. kernel, servers, clients), so walk backwardss. 92 */ 93 mutex_lock(&dev->filelist_mutex); 94 list_for_each_entry_reverse(priv, &dev->filelist, lhead) { 95 bool is_current_master = drm_is_current_master(priv); 96 struct task_struct *task; 97 struct pid *pid; 98 99 mutex_lock(&priv->client_name_lock); 100 rcu_read_lock(); /* Locks priv->pid and pid_task()->comm! */ 101 pid = rcu_dereference(priv->pid); 102 task = pid_task(pid, PIDTYPE_TGID); 103 uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; 104 seq_printf(m, "%20s %5d %3d %c %c %5d %10u %*s %20llu\n", 105 task ? task->comm : "<unknown>", 106 pid_vnr(pid), 107 priv->minor->index, 108 is_current_master ? 'y' : 'n', 109 priv->authenticated ? 'y' : 'n', 110 from_kuid_munged(seq_user_ns(m), uid), 111 priv->magic, 112 DRM_CLIENT_NAME_MAX_LEN, 113 priv->client_name ? priv->client_name : "<unset>", 114 priv->client_id); 115 rcu_read_unlock(); 116 mutex_unlock(&priv->client_name_lock); 117 } 118 mutex_unlock(&dev->filelist_mutex); 119 return 0; 120 } 121 122 static int drm_gem_one_name_info(int id, void *ptr, void *data) 123 { 124 struct drm_gem_object *obj = ptr; 125 struct seq_file *m = data; 126 127 seq_printf(m, "%6d %8zd %7d %8d\n", 128 obj->name, obj->size, 129 obj->handle_count, 130 kref_read(&obj->refcount)); 131 return 0; 132 } 133 134 static int drm_gem_name_info(struct seq_file *m, void *data) 135 { 136 struct drm_debugfs_entry *entry = m->private; 137 struct drm_device *dev = entry->dev; 138 139 seq_printf(m, " name size handles refcount\n"); 140 141 mutex_lock(&dev->object_name_lock); 142 idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m); 143 mutex_unlock(&dev->object_name_lock); 144 145 return 0; 146 } 147 148 static const struct drm_debugfs_info drm_debugfs_list[] = { 149 {"name", drm_name_info, 0}, 150 {"clients", drm_clients_info, 0}, 151 {"gem_names", drm_gem_name_info, DRIVER_GEM}, 152 }; 153 #define DRM_DEBUGFS_ENTRIES ARRAY_SIZE(drm_debugfs_list) 154 155 156 static int drm_debugfs_open(struct inode *inode, struct file *file) 157 { 158 struct drm_info_node *node = inode->i_private; 159 160 if (!device_is_registered(node->minor->kdev)) 161 return -ENODEV; 162 163 return single_open(file, node->info_ent->show, node); 164 } 165 166 static int drm_debugfs_entry_open(struct inode *inode, struct file *file) 167 { 168 struct drm_debugfs_entry *entry = inode->i_private; 169 struct drm_debugfs_info *node = &entry->file; 170 struct drm_minor *minor = entry->dev->primary ?: entry->dev->accel; 171 172 if (!device_is_registered(minor->kdev)) 173 return -ENODEV; 174 175 return single_open(file, node->show, entry); 176 } 177 178 static const struct file_operations drm_debugfs_entry_fops = { 179 .owner = THIS_MODULE, 180 .open = drm_debugfs_entry_open, 181 .read = seq_read, 182 .llseek = seq_lseek, 183 .release = single_release, 184 }; 185 186 static const struct file_operations drm_debugfs_fops = { 187 .owner = THIS_MODULE, 188 .open = drm_debugfs_open, 189 .read = seq_read, 190 .llseek = seq_lseek, 191 .release = single_release, 192 }; 193 194 /** 195 * drm_debugfs_gpuva_info - dump the given DRM GPU VA space 196 * @m: pointer to the &seq_file to write 197 * @gpuvm: the &drm_gpuvm representing the GPU VA space 198 * 199 * Dumps the GPU VA mappings of a given DRM GPU VA manager. 200 * 201 * For each DRM GPU VA space drivers should call this function from their 202 * &drm_info_list's show callback. 203 * 204 * Returns: 0 on success, -ENODEV if the &gpuvm is not initialized 205 */ 206 int drm_debugfs_gpuva_info(struct seq_file *m, 207 struct drm_gpuvm *gpuvm) 208 { 209 struct drm_gpuva *va, *kva = &gpuvm->kernel_alloc_node; 210 211 if (!gpuvm->name) 212 return -ENODEV; 213 214 seq_printf(m, "DRM GPU VA space (%s) [0x%016llx;0x%016llx]\n", 215 gpuvm->name, gpuvm->mm_start, gpuvm->mm_start + gpuvm->mm_range); 216 seq_printf(m, "Kernel reserved node [0x%016llx;0x%016llx]\n", 217 kva->va.addr, kva->va.addr + kva->va.range); 218 seq_puts(m, "\n"); 219 seq_puts(m, " VAs | start | range | end | object | object offset\n"); 220 seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n"); 221 drm_gpuvm_for_each_va(va, gpuvm) { 222 if (unlikely(va == kva)) 223 continue; 224 225 seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n", 226 va->va.addr, va->va.range, va->va.addr + va->va.range, 227 (u64)(uintptr_t)va->gem.obj, va->gem.offset); 228 } 229 230 return 0; 231 } 232 EXPORT_SYMBOL(drm_debugfs_gpuva_info); 233 234 /** 235 * drm_debugfs_create_files - Initialize a given set of debugfs files for DRM 236 * minor 237 * @files: The array of files to create 238 * @count: The number of files given 239 * @root: DRI debugfs dir entry. 240 * @minor: device minor number 241 * 242 * Create a given set of debugfs files represented by an array of 243 * &struct drm_info_list in the given root directory. These files will be removed 244 * automatically on drm_debugfs_dev_fini(). 245 */ 246 void drm_debugfs_create_files(const struct drm_info_list *files, int count, 247 struct dentry *root, struct drm_minor *minor) 248 { 249 struct drm_device *dev = minor->dev; 250 struct drm_info_node *tmp; 251 int i; 252 253 for (i = 0; i < count; i++) { 254 u32 features = files[i].driver_features; 255 256 if (features && !drm_core_check_all_features(dev, features)) 257 continue; 258 259 tmp = drmm_kzalloc(dev, sizeof(*tmp), GFP_KERNEL); 260 if (tmp == NULL) 261 continue; 262 263 tmp->minor = minor; 264 tmp->dent = debugfs_create_file(files[i].name, 265 0444, root, tmp, 266 &drm_debugfs_fops); 267 tmp->info_ent = &files[i]; 268 } 269 } 270 EXPORT_SYMBOL(drm_debugfs_create_files); 271 272 int drm_debugfs_remove_files(const struct drm_info_list *files, int count, 273 struct dentry *root, struct drm_minor *minor) 274 { 275 int i; 276 277 for (i = 0; i < count; i++) { 278 struct dentry *dent = debugfs_lookup(files[i].name, root); 279 280 if (!dent) 281 continue; 282 283 drmm_kfree(minor->dev, d_inode(dent)->i_private); 284 debugfs_remove(dent); 285 } 286 return 0; 287 } 288 EXPORT_SYMBOL(drm_debugfs_remove_files); 289 290 /** 291 * drm_debugfs_dev_init - create debugfs directory for the device 292 * @dev: the device which we want to create the directory for 293 * @root: the parent directory depending on the device type 294 * 295 * Creates the debugfs directory for the device under the given root directory. 296 */ 297 void drm_debugfs_dev_init(struct drm_device *dev, struct dentry *root) 298 { 299 dev->debugfs_root = debugfs_create_dir(dev->unique, root); 300 } 301 302 /** 303 * drm_debugfs_dev_fini - cleanup debugfs directory 304 * @dev: the device to cleanup the debugfs stuff 305 * 306 * Remove the debugfs directory, might be called multiple times. 307 */ 308 void drm_debugfs_dev_fini(struct drm_device *dev) 309 { 310 debugfs_remove_recursive(dev->debugfs_root); 311 dev->debugfs_root = NULL; 312 } 313 314 void drm_debugfs_dev_register(struct drm_device *dev) 315 { 316 drm_debugfs_add_files(dev, drm_debugfs_list, DRM_DEBUGFS_ENTRIES); 317 318 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 319 drm_framebuffer_debugfs_init(dev); 320 drm_client_debugfs_init(dev); 321 } 322 if (drm_drv_uses_atomic_modeset(dev)) 323 drm_atomic_debugfs_init(dev); 324 } 325 326 int drm_debugfs_register(struct drm_minor *minor, int minor_id, 327 struct dentry *root) 328 { 329 struct drm_device *dev = minor->dev; 330 char name[64]; 331 332 sprintf(name, "%d", minor_id); 333 minor->debugfs_symlink = debugfs_create_symlink(name, root, 334 dev->unique); 335 336 /* TODO: Only for compatibility with drivers */ 337 minor->debugfs_root = dev->debugfs_root; 338 339 if (dev->driver->debugfs_init && dev->render != minor) 340 dev->driver->debugfs_init(minor); 341 342 return 0; 343 } 344 345 void drm_debugfs_unregister(struct drm_minor *minor) 346 { 347 debugfs_remove(minor->debugfs_symlink); 348 minor->debugfs_symlink = NULL; 349 } 350 351 /** 352 * drm_debugfs_add_file - Add a given file to the DRM device debugfs file list 353 * @dev: drm device for the ioctl 354 * @name: debugfs file name 355 * @show: show callback 356 * @data: driver-private data, should not be device-specific 357 * 358 * Add a given file entry to the DRM device debugfs file list to be created on 359 * drm_debugfs_init. 360 */ 361 void drm_debugfs_add_file(struct drm_device *dev, const char *name, 362 int (*show)(struct seq_file*, void*), void *data) 363 { 364 struct drm_debugfs_entry *entry = drmm_kzalloc(dev, sizeof(*entry), GFP_KERNEL); 365 366 if (!entry) 367 return; 368 369 entry->file.name = name; 370 entry->file.show = show; 371 entry->file.data = data; 372 entry->dev = dev; 373 374 debugfs_create_file(name, 0444, dev->debugfs_root, entry, 375 &drm_debugfs_entry_fops); 376 } 377 EXPORT_SYMBOL(drm_debugfs_add_file); 378 379 /** 380 * drm_debugfs_add_files - Add an array of files to the DRM device debugfs file list 381 * @dev: drm device for the ioctl 382 * @files: The array of files to create 383 * @count: The number of files given 384 * 385 * Add a given set of debugfs files represented by an array of 386 * &struct drm_debugfs_info in the DRM device debugfs file list. 387 */ 388 void drm_debugfs_add_files(struct drm_device *dev, const struct drm_debugfs_info *files, int count) 389 { 390 int i; 391 392 for (i = 0; i < count; i++) 393 drm_debugfs_add_file(dev, files[i].name, files[i].show, files[i].data); 394 } 395 EXPORT_SYMBOL(drm_debugfs_add_files); 396 397 static int connector_show(struct seq_file *m, void *data) 398 { 399 struct drm_connector *connector = m->private; 400 401 seq_printf(m, "%s\n", drm_get_connector_force_name(connector->force)); 402 403 return 0; 404 } 405 406 static int connector_open(struct inode *inode, struct file *file) 407 { 408 struct drm_connector *dev = inode->i_private; 409 410 return single_open(file, connector_show, dev); 411 } 412 413 static ssize_t connector_write(struct file *file, const char __user *ubuf, 414 size_t len, loff_t *offp) 415 { 416 struct seq_file *m = file->private_data; 417 struct drm_connector *connector = m->private; 418 char buf[12]; 419 420 if (len > sizeof(buf) - 1) 421 return -EINVAL; 422 423 if (copy_from_user(buf, ubuf, len)) 424 return -EFAULT; 425 426 buf[len] = '\0'; 427 428 if (sysfs_streq(buf, "on")) 429 connector->force = DRM_FORCE_ON; 430 else if (sysfs_streq(buf, "digital")) 431 connector->force = DRM_FORCE_ON_DIGITAL; 432 else if (sysfs_streq(buf, "off")) 433 connector->force = DRM_FORCE_OFF; 434 else if (sysfs_streq(buf, "unspecified")) 435 connector->force = DRM_FORCE_UNSPECIFIED; 436 else 437 return -EINVAL; 438 439 return len; 440 } 441 442 static int edid_show(struct seq_file *m, void *data) 443 { 444 return drm_edid_override_show(m->private, m); 445 } 446 447 static int edid_open(struct inode *inode, struct file *file) 448 { 449 struct drm_connector *dev = inode->i_private; 450 451 return single_open(file, edid_show, dev); 452 } 453 454 static ssize_t edid_write(struct file *file, const char __user *ubuf, 455 size_t len, loff_t *offp) 456 { 457 struct seq_file *m = file->private_data; 458 struct drm_connector *connector = m->private; 459 char *buf; 460 int ret; 461 462 buf = memdup_user(ubuf, len); 463 if (IS_ERR(buf)) 464 return PTR_ERR(buf); 465 466 if (len == 5 && !strncmp(buf, "reset", 5)) 467 ret = drm_edid_override_reset(connector); 468 else 469 ret = drm_edid_override_set(connector, buf, len); 470 471 kfree(buf); 472 473 return ret ? ret : len; 474 } 475 476 /* 477 * Returns the min and max vrr vfreq through the connector's debugfs file. 478 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/vrr_range 479 */ 480 static int vrr_range_show(struct seq_file *m, void *data) 481 { 482 struct drm_connector *connector = m->private; 483 484 if (connector->status != connector_status_connected) 485 return -ENODEV; 486 487 seq_printf(m, "Min: %u\n", connector->display_info.monitor_range.min_vfreq); 488 seq_printf(m, "Max: %u\n", connector->display_info.monitor_range.max_vfreq); 489 490 return 0; 491 } 492 DEFINE_SHOW_ATTRIBUTE(vrr_range); 493 494 /* 495 * Returns Connector's max supported bpc through debugfs file. 496 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc 497 */ 498 static int output_bpc_show(struct seq_file *m, void *data) 499 { 500 struct drm_connector *connector = m->private; 501 502 if (connector->status != connector_status_connected) 503 return -ENODEV; 504 505 seq_printf(m, "Maximum: %u\n", connector->display_info.bpc); 506 507 return 0; 508 } 509 DEFINE_SHOW_ATTRIBUTE(output_bpc); 510 511 static const struct file_operations drm_edid_fops = { 512 .owner = THIS_MODULE, 513 .open = edid_open, 514 .read = seq_read, 515 .llseek = seq_lseek, 516 .release = single_release, 517 .write = edid_write 518 }; 519 520 521 static const struct file_operations drm_connector_fops = { 522 .owner = THIS_MODULE, 523 .open = connector_open, 524 .read = seq_read, 525 .llseek = seq_lseek, 526 .release = single_release, 527 .write = connector_write 528 }; 529 530 static ssize_t 531 audio_infoframe_read(struct file *filp, char __user *ubuf, size_t count, loff_t *ppos) 532 { 533 struct drm_connector_hdmi_infoframe *infoframe; 534 struct drm_connector *connector; 535 union hdmi_infoframe *frame; 536 u8 buf[HDMI_INFOFRAME_SIZE(AUDIO)]; 537 ssize_t len = 0; 538 539 connector = filp->private_data; 540 mutex_lock(&connector->hdmi.infoframes.lock); 541 542 infoframe = &connector->hdmi.infoframes.audio; 543 if (!infoframe->set) 544 goto out; 545 546 frame = &infoframe->data; 547 len = hdmi_infoframe_pack(frame, buf, sizeof(buf)); 548 if (len < 0) 549 goto out; 550 551 len = simple_read_from_buffer(ubuf, count, ppos, buf, len); 552 553 out: 554 mutex_unlock(&connector->hdmi.infoframes.lock); 555 return len; 556 } 557 558 static const struct file_operations audio_infoframe_fops = { 559 .owner = THIS_MODULE, 560 .open = simple_open, 561 .read = audio_infoframe_read, 562 }; 563 564 static int create_hdmi_audio_infoframe_file(struct drm_connector *connector, 565 struct dentry *parent) 566 { 567 struct dentry *file; 568 569 file = debugfs_create_file("audio", 0400, parent, connector, &audio_infoframe_fops); 570 if (IS_ERR(file)) 571 return PTR_ERR(file); 572 573 return 0; 574 } 575 576 #define DEFINE_INFOFRAME_FILE(_f) \ 577 static ssize_t _f##_read_infoframe(struct file *filp, \ 578 char __user *ubuf, \ 579 size_t count, \ 580 loff_t *ppos) \ 581 { \ 582 struct drm_connector_hdmi_infoframe *infoframe; \ 583 struct drm_connector_state *conn_state; \ 584 struct drm_connector *connector; \ 585 union hdmi_infoframe *frame; \ 586 struct drm_device *dev; \ 587 u8 buf[HDMI_INFOFRAME_SIZE(MAX)]; \ 588 ssize_t len = 0; \ 589 \ 590 connector = filp->private_data; \ 591 dev = connector->dev; \ 592 \ 593 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); \ 594 \ 595 conn_state = connector->state; \ 596 infoframe = &conn_state->hdmi.infoframes._f; \ 597 if (!infoframe->set) \ 598 goto out; \ 599 \ 600 frame = &infoframe->data; \ 601 len = hdmi_infoframe_pack(frame, buf, sizeof(buf)); \ 602 if (len < 0) \ 603 goto out; \ 604 \ 605 len = simple_read_from_buffer(ubuf, count, ppos, buf, len); \ 606 \ 607 out: \ 608 drm_modeset_unlock(&dev->mode_config.connection_mutex); \ 609 return len; \ 610 } \ 611 \ 612 static const struct file_operations _f##_infoframe_fops = { \ 613 .owner = THIS_MODULE, \ 614 .open = simple_open, \ 615 .read = _f##_read_infoframe, \ 616 }; \ 617 \ 618 static int create_hdmi_## _f ## _infoframe_file(struct drm_connector *connector, \ 619 struct dentry *parent) \ 620 { \ 621 struct dentry *file; \ 622 \ 623 file = debugfs_create_file(#_f, 0400, parent, connector, &_f ## _infoframe_fops); \ 624 if (IS_ERR(file)) \ 625 return PTR_ERR(file); \ 626 \ 627 return 0; \ 628 } 629 630 DEFINE_INFOFRAME_FILE(avi); 631 DEFINE_INFOFRAME_FILE(hdmi); 632 DEFINE_INFOFRAME_FILE(hdr_drm); 633 DEFINE_INFOFRAME_FILE(spd); 634 635 static int create_hdmi_infoframe_files(struct drm_connector *connector, 636 struct dentry *parent) 637 { 638 int ret; 639 640 ret = create_hdmi_audio_infoframe_file(connector, parent); 641 if (ret) 642 return ret; 643 644 ret = create_hdmi_avi_infoframe_file(connector, parent); 645 if (ret) 646 return ret; 647 648 ret = create_hdmi_hdmi_infoframe_file(connector, parent); 649 if (ret) 650 return ret; 651 652 ret = create_hdmi_hdr_drm_infoframe_file(connector, parent); 653 if (ret) 654 return ret; 655 656 ret = create_hdmi_spd_infoframe_file(connector, parent); 657 if (ret) 658 return ret; 659 660 return 0; 661 } 662 663 static void hdmi_debugfs_add(struct drm_connector *connector) 664 { 665 struct dentry *dir; 666 667 if (!(connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || 668 connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) 669 return; 670 671 dir = debugfs_create_dir("infoframes", connector->debugfs_entry); 672 if (IS_ERR(dir)) 673 return; 674 675 create_hdmi_infoframe_files(connector, dir); 676 } 677 678 void drm_debugfs_connector_add(struct drm_connector *connector) 679 { 680 struct drm_device *dev = connector->dev; 681 struct dentry *root; 682 683 if (!dev->debugfs_root) 684 return; 685 686 root = debugfs_create_dir(connector->name, dev->debugfs_root); 687 connector->debugfs_entry = root; 688 689 /* force */ 690 debugfs_create_file("force", 0644, root, connector, 691 &drm_connector_fops); 692 693 /* edid */ 694 debugfs_create_file("edid_override", 0644, root, connector, 695 &drm_edid_fops); 696 697 /* vrr range */ 698 debugfs_create_file("vrr_range", 0444, root, connector, 699 &vrr_range_fops); 700 701 /* max bpc */ 702 debugfs_create_file("output_bpc", 0444, root, connector, 703 &output_bpc_fops); 704 705 hdmi_debugfs_add(connector); 706 707 if (connector->funcs->debugfs_init) 708 connector->funcs->debugfs_init(connector, root); 709 } 710 711 void drm_debugfs_connector_remove(struct drm_connector *connector) 712 { 713 if (!connector->debugfs_entry) 714 return; 715 716 debugfs_remove_recursive(connector->debugfs_entry); 717 718 connector->debugfs_entry = NULL; 719 } 720 721 void drm_debugfs_crtc_add(struct drm_crtc *crtc) 722 { 723 struct drm_device *dev = crtc->dev; 724 struct dentry *root; 725 char *name; 726 727 name = kasprintf(GFP_KERNEL, "crtc-%d", crtc->index); 728 if (!name) 729 return; 730 731 root = debugfs_create_dir(name, dev->debugfs_root); 732 kfree(name); 733 734 crtc->debugfs_entry = root; 735 736 drm_debugfs_crtc_crc_add(crtc); 737 } 738 739 void drm_debugfs_crtc_remove(struct drm_crtc *crtc) 740 { 741 debugfs_remove_recursive(crtc->debugfs_entry); 742 crtc->debugfs_entry = NULL; 743 } 744 745 void drm_debugfs_encoder_add(struct drm_encoder *encoder) 746 { 747 struct drm_minor *minor = encoder->dev->primary; 748 struct dentry *root; 749 char *name; 750 751 name = kasprintf(GFP_KERNEL, "encoder-%d", encoder->index); 752 if (!name) 753 return; 754 755 root = debugfs_create_dir(name, minor->debugfs_root); 756 kfree(name); 757 758 encoder->debugfs_entry = root; 759 760 drm_bridge_debugfs_encoder_params(root, encoder); 761 762 if (encoder->funcs && encoder->funcs->debugfs_init) 763 encoder->funcs->debugfs_init(encoder, root); 764 } 765 766 void drm_debugfs_encoder_remove(struct drm_encoder *encoder) 767 { 768 debugfs_remove_recursive(encoder->debugfs_entry); 769 encoder->debugfs_entry = NULL; 770 } 771