Re: Get SPDIF-in sample rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-07-19 8:46 GMT+02:00 Clemens Ladisch <clemens@xxxxxxxxxx>:
The HID interface is managed by another driver.  The kernel driver
already knows how to write to these registers with a control request
instead (see below).  Could you check if a control read request works,
or if the response still goes through the HID pipe?

I've tried that, but unfortunately it didn't work. The input request reads zero bytes.
Well, I think that means I'll have to use my workarount with libhidapi.
Below is my code. I don't feel very confident on all those bmRequestType, bRequest, wValue and other parameters, I just used the ones from your example. May be later I will be able to sniff the communication of the card with its proprietary Windows driver, and if I get a different results I'll revert back to you.

int cm106_read(libusb_device_handle *handle, char reg, uint16_t *data)
{
        int res;
        unsigned char buf[4] = {0x30,   // 0x20 to write, 0x30 to read
                                0x00,   // DATAL
                                0x00,   // DATAH
                                reg};   // Register address

        if ((res = libusb_control_transfer(handle, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_ENDPOINT,
                                           LIBUSB_REQUEST_SET_CONFIGURATION, 0, 0, buf, 4, 0)) != 4)
                return res;

        if ((res = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_ENDPOINT,
                                           LIBUSB_REQUEST_SET_CONFIGURATION, 0, 0, buf, 4, 0)) < 0) // <-- THIS FUNCTION RETURNS 0
                return res;

        if (res != 3)
        {
                fprintf(stderr, "DEBUG Invalid response length"
                return -1;
        }

        if (buf[0] & 0xe0 != 0x20)      // No register data in the input
        {
                fprintf(stderr, "DEBUG data: %02X %02X %02X\n", buf[0], buf[1], buf[2]);
                return -1;
        }

        *data = "" << 8) + buf[1];
        return 0;
}

// Just for completeness, the below function successfully writes the data into cm106 registers
int cm106_write(libusb_device_handle *handle, char reg, uint16_t data)
{
        unsigned char buf[4] = {0x20,                   // 0x20 to write, 0x30 to read
                                data & 0xff,            // DATAL
                                (data >> 8) & 0xff,     // DATAH
                                reg};                   // Register address

        return libusb_control_transfer(handle, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_ENDPOINT,
                                           LIBUSB_REQUEST_SET_CONFIGURATION, 0, 0, buf, 4, 0);
}


Thank you for your support!

Best regards
Denis Shulyaka
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux