Hi, I want to make a control program for an EIZO FlexScan T965 CRT monitor. The monitor keys are reported to hiddev. Setting brightness, contrast etc is done with control messages. I have attached a libusb program that does this, but it only works if usbhid.ko is unloaded. I have not found an ioctl in hiddev.c that can be used to send this kind of control messages.
What would be the right/preferred way to make such a monitor control? Implement an ioctl in hiddev.c or put the device to hid_blacklist? Make a user space program or a kernel module? Is there anyone working on a monitor control for this or another monitor already? I have only found tools for USV. Thanks, Jan
/* * EIZO FlexScan T965 USB Monitor Control * * based on set_led (see http://www.linuxjournal.com/article.php?sid=7466) * Copyright (C) 2004 Greg Kroah-Hartman ([EMAIL PROTECTED]) * * Copyright (c) 2004 Jan Steinhoff <[EMAIL PROTECTED]> * * Currently only setting and reading monitor brightness are supported * * This program is free software; you can * redistribute it and/or modify it under the terms * of the GNU General Public License as published by * the Free Software Foundation, version 2 of the * License. * * Trademarks are the property of their respective owners. */ #include <stdio.h> #include <usb.h> #define EIZO_VENDOR_ID 0x056d #define EIZO_T965_PRODUCT_ID 0x0002 static int set_brightness(struct usb_dev_handle *handle, unsigned int brightness) { unsigned char data[3]; data[0] = 0x01; data[1] = brightness & 0xff; data[2] = brightness >> 8; return usb_control_msg(handle, 0x21, 0x09, 0x0301, 0, (char*) &data, sizeof(data), 1000); } static int get_brightness(struct usb_dev_handle *handle) { unsigned char data[3]; int retval; retval = usb_control_msg(handle, 0xa1, 0x01, 0x0301, 0, (char*) &data, sizeof(data), 1000); if (retval < 0) { return retval; } else { return data[1] + (data[2] << 8); } } static struct usb_device *device_init(void) { struct usb_bus *usb_bus; struct usb_device *dev; usb_init(); usb_find_busses(); usb_find_devices(); for (usb_bus = usb_busses; usb_bus; usb_bus = usb_bus->next) { for (dev = usb_bus->devices; dev;dev = dev->next) { if ((dev->descriptor.idVendor == EIZO_VENDOR_ID) && (dev->descriptor.idProduct == EIZO_T965_PRODUCT_ID)) return dev; } } return NULL; } static void print_usage() { fprintf(stderr, "Syntax Error\n" "Usage: eizo-usb [brightness]\n"); } int main(int argc, char **argv) { struct usb_device *usb_dev; struct usb_dev_handle *usb_handle; int retval = 1; unsigned int brightness; usb_dev = device_init(); if (usb_dev == NULL) { fprintf(stderr, "Device not found\n"); return 1; } usb_handle = usb_open(usb_dev); if (usb_handle == NULL) { perror("Not able to claim the USB device"); return 1; } if (argc > 2) { print_usage(); goto error; } if (argc == 2) { if (sscanf(argv[1], "%u", &brightness) != 1) { print_usage(); goto error; } if (brightness > 400) { fprintf(stderr, "Brightness out of range\n"); goto error; } retval = set_brightness(usb_handle, brightness); if (retval < 0) { perror("Can not set brightness"); goto error; } } retval = get_brightness(usb_handle); if (retval < 0) { perror("Can not get brightness"); goto error; } printf("Brightness: %i\n", retval); retval = 0; error: usb_close(usb_handle); return retval; }