Hi.

I am currently trying to talk to my monitor using the hiddev USB interface.
Reading from the device works just fine, I can issue HIDIOCGDEVINFO, enumerate
the reports, fields and usages with HIDIOCGREPORTINFO, HIDIOCGFIELDINFO and
HIDIOCGUCODE/HIDIOCGUSAGE, and events from using the monitor OSD are delivered
to read(). So far, so good.

What I am failing at is writing a value to the device. The only documentation
I have found is usb/hiddev.txt in the linux kernel documentation tree.
According to this text, I have to prepare a struct hiddev_usage_ref with
the usage code and value I want to issue to the device, call HIDIOCSUSAGE,
prepare a struct hiddev_report_info and call HIDIOCSREPORT to send the
report containing the new values to the device.

I am hanging at the HIDIOCSUSAGE stage. No matter what values I enter into
the structure before sending the ioctl, I always get -EINVAL as the return
code.

The code in question is below. fd is an open file descriptor to the device
file. _ERROR, _DEBUG, _ENTER and _LEAVE are just helper macros which are
not important here.

Any thoughts on what I am doing wrong?

Thanks.

----------------------

void set_brightness(int fd, int brightness) {

    struct hiddev_report_info report;
    struct hiddev_usage_ref usage;

    _ENTER;

    usage.report_type = HID_REPORT_TYPE_INPUT;
    usage.report_id = HID_REPORT_ID_UNKNOWN;
    usage.usage_code = 0x00820010;

    if (0 != ioctl(fd, HIDIOCGUSAGE, &usage)) {
        _ERROR("Error during ioctl HIDIOCGUSAGE!");
        _LEAVE;
    }

    _DEBUG("Usage found: report %08X, field %08X, usage %08X",
        usage.report_id, usage.field_index, usage.usage_index);

    usage.report_type = HID_REPORT_TYPE_OUTPUT;
    usage.value = brightness;

    if (0 != ioctl(fd, HIDIOCSUSAGE, &usage)) {
        _ERROR("Error during ioctl HIDIOCSUSAGE!");
        _LEAVE;
    }

    report.report_type = HID_REPORT_TYPE_OUTPUT;
    report.report_id = 0;
    report.num_fields = 1;

    if (0 != ioctl(fd, HIDIOCSREPORT, &report)) {
        _ERROR("Error during ioctl HIDIOCSREPORT!");
        _LEAVE;
    }

    _LEAVE;
}

-- 
My Uncle Larry has a saying, "Never play proctologist with an unwilling
goose."  Okay, so Uncle Larry drinks a bit.  -- Yobaval


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-usb-users@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to