[igt-dev] [PATCH i-g-t 1/4] lib/igt_kms: Add igt_connector_sysfs_open()

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 3 16:22:05 UTC 2019


Quoting Ville Syrjala (2019-12-03 15:35:52)
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Add a helper to open the sysfs directory for a connector.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h |  3 +++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 44647a2263bd..74ae98d774f1 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -965,6 +965,40 @@ static void reset_connectors_at_exit(int sig)
>         igt_reset_connectors();
>  }
>  
> +static char *kmstest_connector_dirname(int idx,
> +                                      uint32_t connector_type,
> +                                      uint32_t connector_type_id,
> +                                      char *name, int namelen)
> +{
> +       snprintf(name, namelen, "card%d-%s-%d", idx,
> +                kmstest_connector_type_str(connector_type),
> +                connector_type_id);
> +
> +       return name;
> +}
> +
> +int igt_connector_sysfs_open(int drm_fd,
> +                            drmModeConnector *connector)
> +{
> +       char name[80];
> +       int dir, conn_dir;
> +
> +       dir = igt_sysfs_open(drm_fd);
> +       if (dir < 0)
> +               return dir;
> +
> +       if (!kmstest_connector_dirname(igt_device_get_card_index(drm_fd),
> +                                      connector->connector_type,
> +                                      connector->connector_type_id,
> +                                      name, sizeof(name)))
> +               return -1;

Before igt_sysfs_open() or close(dir);

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list