sysfs

sysfs — Support code for sysfs features

Functions

Includes

#include <igt.h>

Description

This library provides helpers to access sysfs features. Right now it only provides basic support for like igt_sysfs_open().

Functions

igt_sysfs_path ()

char *
igt_sysfs_path (int device,
                char *path,
                int pathlen,
                int *idx);

This finds the sysfs directory corresponding to device .

Parameters

device

fd of the device (or -1 to default to Intel)

 

path

buffer to fill with the sysfs path to the device

 

pathlen

length of path buffer

 

idx

optional pointer to store the card index of the opened device

 

Returns

The directory path, or NULL on failure.


igt_sysfs_open ()

int
igt_sysfs_open (int device,
                int *idx);

This opens the sysfs directory corresponding to device for use with igt_sysfs_set() and igt_sysfs_get().

Parameters

device

fd of the device (or -1 to default to Intel)

 

idx

optional pointer to store the card index of the opened device

 

Returns

The directory fd, or -1 on failure.


igt_sysfs_open_parameters ()

int
igt_sysfs_open_parameters (int device);

This opens the module parameters directory (under sysfs) corresponding to the device for use with igt_sysfs_set() and igt_sysfs_get().

Parameters

device

fd of the device (or -1 to default to Intel)

 

Returns

The directory fd, or -1 on failure.


igt_sysfs_set_parameter ()

bool
igt_sysfs_set_parameter (int device,
                         const char *parameter,
                         const char *fmt,
                         ...);

igt_sysfs_read ()

int
igt_sysfs_read (int dir,
                const char *attr,
                void *data,
                int len);

This reads len bytes from the sysfs file to data

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

data

the block to read into

 

len

the maximum length to read

 

Returns

The length read, -errno on failure.


igt_sysfs_write ()

int
igt_sysfs_write (int dir,
                 const char *attr,
                 const void *data,
                 int len);

This writes len bytes from data to the sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

data

the block to write from

 

len

the length to write

 

Returns

The number of bytes written, or -errno on error.


igt_sysfs_set ()

bool
igt_sysfs_set (int dir,
               const char *attr,
               const char *value);

This writes the value to the sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

value

the string to write

 

Returns

True on success, false on failure.


igt_sysfs_get ()

char *
igt_sysfs_get (int dir,
               const char *attr);

This reads the value from the sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

Returns

A nul-terminated string, must be freed by caller after use, or NULL on failure.


igt_sysfs_scanf ()

int
igt_sysfs_scanf (int dir,
                 const char *attr,
                 const char *fmt,
                 ...);

scanf() wrapper for sysfs.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

fmt

scanf format string

 

...

Additional paramaters to store the scaned input values

 

Returns

Number of values successfully scanned (which can be 0), EOF on errors or premature end of file.


igt_sysfs_vprintf ()

int
igt_sysfs_vprintf (int dir,
                   const char *attr,
                   const char *fmt,
                   va_list ap);

igt_sysfs_printf ()

int
igt_sysfs_printf (int dir,
                  const char *attr,
                  const char *fmt,
                  ...);

printf() wrapper for sysfs.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

fmt

printf format string

 

...

Additional paramaters to store the scaned input values

 

Returns

Number of characters written, negative value on error.


igt_sysfs_get_u32 ()

uint32_t
igt_sysfs_get_u32 (int dir,
                   const char *attr);

Convenience wrapper to read a unsigned 32bit integer from a sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

Returns

The value read.


igt_sysfs_set_u32 ()

bool
igt_sysfs_set_u32 (int dir,
                   const char *attr,
                   uint32_t value);

Convenience wrapper to write a unsigned 32bit integer to a sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

value

value to set

 

Returns

True if successfully written


igt_sysfs_get_boolean ()

bool
igt_sysfs_get_boolean (int dir,
                       const char *attr);

Convenience wrapper to read a boolean sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

Returns

The value read.


igt_sysfs_set_boolean ()

bool
igt_sysfs_set_boolean (int dir,
                       const char *attr,
                       bool value);

Convenience wrapper to write a boolean sysfs file.

Parameters

dir

directory for the device from igt_sysfs_open()

 

attr

name of the sysfs node to open

 

value

value to set

 

Returns

The value read.


kick_fbcon ()

void
kick_fbcon (bool enable);

This functions enables/disables the text console running on top of the framebuffer device.

Parameters

enable

boolean value

 

kick_snd_hda_intel ()

void
kick_snd_hda_intel (void);

This functions unbinds the snd_hda_intel driver so the module cand be unloaded.

Types and Values