All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH libdrm 3/3] tests/util: Add some API documentation
Date: Mon, 30 Jan 2017 11:29:23 +0100	[thread overview]
Message-ID: <20170130102923.1991-3-thierry.reding@gmail.com> (raw)
In-Reply-To: <20170130102923.1991-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

None of the helpers currently have any documentation. Add some to make
it more obvious how these should be used.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/util/kms.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/util/kms.c b/tests/util/kms.c
index c5d35ab616d1..226386519d49 100644
--- a/tests/util/kms.c
+++ b/tests/util/kms.c
@@ -128,6 +128,13 @@ const char *util_lookup_connector_type_name(unsigned int type)
                                  ARRAY_SIZE(connector_type_names));
 }
 
+/**
+ * Retrieve the name of the kernel driver for a DRM device.
+ *
+ * \param fd the file descriptor of the DRM device
+ *
+ * \return On success, returns the name of the kernel driver.
+ */
 char *util_get_driver(int fd)
 {
     drmVersionPtr version;
@@ -144,6 +151,16 @@ char *util_get_driver(int fd)
     return driver;
 }
 
+/**
+ * Retrieve a list of available DRM devices.
+ *
+ * \param devicesp return location for the list of DRM devices
+ * \param flags bitmask of flags controlling operation
+ *
+ * \return On success, returns the number of devices found. The list of DRM
+ * devices is dynamically allocated and needs to be freed by a call to the
+ * util_free_devices() function.
+ */
 int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
 {
     drmDevicePtr *devices;
@@ -182,12 +199,32 @@ int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
     return count;
 }
 
+/**
+ * Free a list of DRM devices.
+ *
+ * \param devices a list of DRM devices, allocated by util_get_devices()
+ * \param count the number of DRM devices in \p devices
+ */
 void util_free_devices(drmDevicePtr *devices, unsigned int count)
 {
     drmFreeDevices(devices, count);
     free(devices);
 }
 
+/**
+ * Opens a DRM device, optionally checking against its kernel driver.
+ *
+ * \param device path to DRM device
+ * \param module optional name of kernel driver
+ *
+ * \return On success, a file descriptor to \p device, or a negative error
+ * code on failure.
+ *
+ * If the caller doesn't care about the kernel driver associated with the DRM
+ * device, then the \p module parameter can be NULL. If \p module is not NULL
+ * this function will retrieve the name of the kernel driver and compare it
+ * to the \p module parameter. If the names don't match, the call will fail.
+ */
 int util_open_with_module(const char *device, const char *module)
 {
     int fd, err = 0;
@@ -229,6 +266,20 @@ out:
     return err;
 }
 
+/**
+ * Opens a DRM device, optionally checking against its kernel driver.
+ *
+ * \param device
+ * \param module
+ *
+ * \return On success, a file descriptor to \p device, or a negative error
+ * code on failure.
+ *
+ * This is similar to util_open_with_module(), except that \p device can be
+ * NULL, in which case all available devices will be tried. If \p module is
+ * specified it will act as a filter. Otherwise the first available device
+ * that can be opened will be used.
+ */
 int util_open(const char *device, const char *module)
 {
     int fd, err;
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-01-30 10:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30 10:29 [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
2017-02-01 12:47   ` Emil Velikov
2017-02-01 15:59     ` Thierry Reding
2017-01-30 10:29 ` Thierry Reding [this message]
2017-01-30 10:32 ` [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170130102923.1991-3-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.