bits_per_pixel console dev mode pan state uevent blank cursor device modes power stride virtual_size bl_curve debug gamma name rotate subsystem这里面没有你说的文件怎么办
时间: 2024-02-10 09:05:07 浏览: 26
如果你的 Linux 系统没有 `/sys/class/graphics/fb0/invert_display` 文件,可能是因为你的系统的内核中没有开启对应的功能。在这种情况下,你可以尝试使用其他方法来实现颜色反转。
一种方法是使用 `xcalib` 工具来实现颜色反转。`xcalib` 是一个用于设置 X11 显示颜色的工具,它可以实现颜色反转的功能。你可以使用以下命令安装 `xcalib`:
```
sudo apt-get install xcalib
```
安装完成后,你可以使用以下命令来反转颜色:
```
xcalib -invert -alter
```
这个命令将会反转整个 X11 显示器的颜色。如果你只想反转特定的窗口,可以使用 `-id` 选项指定窗口 ID。你可以使用 `xwininfo` 命令来获取窗口 ID。
另外,还有一种方法是使用 `xrandr` 工具来实现颜色反转。你可以使用以下命令来查看可用的输出设备:
```
xrandr -q
```
然后,你可以使用以下命令来反转颜色:
```
xrandr --output <output_device> --invert
```
其中,`<output_device>` 是你要反转颜色的设备名称。这个方法适用于 X11 显示器,不适用于 Linux fb 设备。
相关问题
ls /sys/bus/i2c/devices/i2c-0/ 查看设备时,会出现0-0042 delete_device i2c-dev new_device power uevent 0-0043 device name of_node subsystem waiting_for_supplier
在 `/sys/bus/i2c/devices/i2c-0/` 目录下,`0-0042` 和 `0-0043` 分别表示在 i2c bus 0 上注册的两个 i2c 设备,它们的具体地址分别为 0x42 和 0x43。`device` 目录下是与该 i2c bus 相关的一些设备文件,其中 `name` 文件记录了该 i2c bus 的名称,`of_node` 文件记录了该 i2c bus 在设备树中的节点信息,`subsystem` 目录下是 i2c 设备子系统相关的一些设备文件,例如 `i2c-dev` 文件是 i2c 设备的字符设备文件,可以通过该文件与 i2c 设备进行通信。`new_device` 和 `delete_device` 文件可以用来动态添加和删除 i2c 设备。`power` 目录下是与 i2c 设备电源管理相关的一些设备文件,`uevent` 文件记录了该 i2c bus 的 uevent 信息。`waiting_for_supplier` 文件用于 i2c 设备的热插拔,表示该 i2c 设备正在等待新的供应者。
g_uevent_device_new 代码举例
以下是一个简单的 g_uevent_device_new 函数实现的示例代码:
```c
#include <glib.h>
#include <gio/gio.h>
#define UEVENT_BUFFER_SIZE 2048
typedef struct _GUeventDevice GUeventDevice;
struct _GUeventDevice {
GObject parent_instance;
gchar *syspath;
gchar *subsystem;
gchar *devtype;
gchar **filters;
GRegex **regex_filters;
guint n_filters;
GIOChannel *io_channel;
guint io_watch_id;
gchar io_buffer[UEVENT_BUFFER_SIZE];
};
G_DEFINE_TYPE(GUeventDevice, g_uevent_device, G_TYPE_OBJECT);
static gboolean
g_uevent_device_io_watch_callback(GIOChannel *channel, GIOCondition condition,
gpointer user_data)
{
GUeventDevice *self = G_UEVENT_DEVICE(user_data);
if (condition & G_IO_IN) {
gsize bytes_read = 0;
gsize io_buffer_size = sizeof(self->io_buffer) - 1;
if (g_io_channel_read_chars(channel, self->io_buffer, io_buffer_size,
&bytes_read, NULL) != G_IO_ERROR_NONE) {
g_warning("Failed to read from uevent device");
return G_SOURCE_REMOVE;
}
/* Null-terminate the read buffer */
self->io_buffer[bytes_read] = '\0';
/* Process the uevent messages in the buffer */
gchar *line_start = self->io_buffer;
gchar *line_end = NULL;
while ((line_end = strchr(line_start, '\n'))) {
*line_end = '\0';
gchar **kv_pairs = g_strsplit(line_start, "=", -1);
/* Process the key-value pairs in the uevent message */
for (guint i = 0; kv_pairs[i]; i += 2) {
gchar *key = kv_pairs[i];
gchar *value = kv_pairs[i + 1];
/* Filter out the key-value pairs that don't match any of the
regex filters */
gboolean filter_match = FALSE;
for (guint j = 0; j < self->n_filters; j++) {
if (g_regex_match(self->regex_filters[j], key, 0, NULL)) {
filter_match = TRUE;
break;
}
}
if (!filter_match) {
continue;
}
g_message("Received uevent message: %s=%s", key, value);
}
g_strfreev(kv_pairs);
line_start = line_end + 1;
}
}
return G_SOURCE_CONTINUE;
}
static void
g_uevent_device_init(GUeventDevice *self)
{
self->syspath = NULL;
self->subsystem = NULL;
self->devtype = NULL;
self->filters = NULL;
self->regex_filters = NULL;
self->n_filters = 0;
self->io_channel = NULL;
self->io_watch_id = 0;
}
static void
g_uevent_device_class_init(GUeventDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = (GObjectFinalizeFunc) g_free;
}
GUeventDevice *
g_uevent_device_new(const gchar *syspath, const gchar *subsystem,
const gchar *devtype, gchar **filters)
{
GUeventDevice *self = g_object_new(G_TYPE_UEVENT_DEVICE, NULL);
self->syspath = g_strdup(syspath);
self->subsystem = g_strdup(subsystem);
self->devtype = g_strdup(devtype);
self->filters = g_strdupv(filters);
/* Compile the regex filters */
for (guint i = 0; self->filters[i]; i++) {
GRegex *regex_filter = g_regex_new(self->filters[i], 0, 0, NULL);
if (!regex_filter) {
g_warning("Failed to compile regex filter: %s", self->filters[i]);
continue;
}
self->regex_filters = g_realloc(self->regex_filters,
(self->n_filters + 1) * sizeof(GRegex *));
self->regex_filters[self->n_filters++] = regex_filter;
}
/* Open the uevent device file */
gchar *uevent_path = g_build_filename(self->syspath, "uevent", NULL);
GError *error = NULL;
self->io_channel = g_io_channel_new_file(uevent_path, "r", &error);
if (!self->io_channel) {
g_warning("Failed to open uevent device: %s", error->message);
g_error_free(error);
g_object_unref(self);
return NULL;
}
/* Add a watch for the IO channel */
self->io_watch_id = g_io_add_watch(self->io_channel, G_IO_IN,
g_uevent_device_io_watch_callback, self);
g_free(uevent_path);
return self;
}
```
这个示例代码演示了如何使用 GLib 和 GIO 库来创建一个 GUeventDevice 对象,该对象可以通过监听 Linux 内核的 uevent 消息来获取设备事件。GUeventDevice 对象可以指定一些过滤器,以只接收特定的 uevent 消息。在对象的销毁期间,将释放所有内存和资源。