Skip to content

Commit

Permalink
Bugfix for intel chipsets and couple improvements
Browse files Browse the repository at this point in the history
* Changed min & max input & output levels
* Added read response from hid request: fixes #1
* Added headphone init to the defaults
  • Loading branch information
rabits committed Jul 22, 2018
1 parent 583385a commit 74b543c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ $ maya22-control -h
Usage: ./maya22-control [options]
-e - Enumerate available devices
-i - Enable headphone
-d - Set default values
-c <name> - Set input channel ('mic', 'hiz', 'line', 'mic_hiz', 'mute')
-M - Input monitoring on
-m - Input monitoring off
-l <0-255> - Input left volume
-r <0-255> - Input right volume
-L <0-255> - Output left volume
-R <0-255> - Output right volume
-l <0-127> - Input left volume
-r <0-127> - Input right volume
-L <0-145> - Output left volume (seems 127 without gain and > with gain)
-R <0-145> - Output right volume (seems 127 without gain and > with gain)
```

Udev permissions & autoset defaults
Expand All @@ -37,3 +38,8 @@ Just create udev rule for hidraw device with autorun set defaults (/etc/udev/rul
```
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2573", ATTRS{idProduct}=="0017", GROUP="plugdev", MODE="0660", RUN+="/usr/local/bin/maya22-control -d"
```

GUI application
---------------
You can find GUI more useful for your needs, so please check the following project:
* https://gitlab.com/Psy-Kai/ESI-Maya22USBControl
59 changes: 31 additions & 28 deletions maya22-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,32 @@ void enumerate_hid()

int send(hid_device *dev, unsigned char op, unsigned char byte)
{
unsigned char buf[] = {0x00,
0x12, 0x34, op, 0x00, 0x01,
byte, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00
};
unsigned char buf[33]; // +1 byte for report id
memset(buf, 0, sizeof(buf));
buf[1] = 0x12;
buf[2] = 0x34;
buf[3] = op;
buf[5] = 1;
buf[6] = byte;
buf[22] = 0x80;

int res = hid_write(dev, buf, sizeof(buf));

if( res < 0 )
if( res < 0 ) {
wprintf(L"ERROR: Operation failed: %d\n", res);
return res;
}

return res;
// Waiting response
return hid_read(dev, buf, sizeof(buf));
}

int main(int argc, char *argv[])
{
// Options values
long input_l = 190, input_r = 190, output_l = 255, output_r = 255;
long input_l = 86, input_r = 86, output_l = 145, output_r = 145;
bool monitor = false, input_mute = false;
unsigned char input_channel = 0x8; // MIC: 0x1, HIZ: 0x2, LINE: 0x4, MIC_HIZ: 0x8, MUTE: 0xc2
unsigned char input_channel = 0x8; // MIC: 0x1, HIZ: 0x2, LINE: 0x4, MIC_HIZ: 0x8, MUTE: 0xc1 (depends on selected channel, (0xc0 || channel))

bool do_e = false, do_i = false, do_c = false, do_m = false, do_l = false, do_r = false, do_L = false, do_R = false;

Expand All @@ -81,15 +84,15 @@ int main(int argc, char *argv[])
do_i = true;
break;
case 'd':
do_c = true; do_m = true; do_l = true; do_r = true; do_L = true; do_R = true;
do_i = true; do_c = true; do_m = true; do_l = true; do_r = true; do_L = true; do_R = true;
break;
case 'c':
do_c = true;
if( optarg[0] == 'm' ) {
if( optarg[strlen(optarg)-1] == 'z' )
input_channel = 0x8;
else if( optarg[strlen(optarg)-1] == 'e' )
input_channel = 0xc2;
input_channel = 0xc1; // Only one channel here due to the app interface
else
input_channel = 0x1;
}
Expand All @@ -108,35 +111,35 @@ int main(int argc, char *argv[])
case 'l':
do_l = true;
input_l = atoi(optarg);
input_l = max(min(input_l, 255), 0);
input_l = max(min(input_l, 127), 0);
break;
case 'r':
do_r = true;
input_r = atoi(optarg);
input_r = max(min(input_r, 255), 0);
input_r = max(min(input_r, 127), 0);
break;
case 'L':
do_L = true;
output_l = atoi(optarg);
output_l = max(min(output_l, 255), 0);
output_l = max(min(output_l, 145), 0);
break;
case 'R':
do_R = true;
output_r = atoi(optarg);
output_r = max(min(output_r, 255), 0);
output_r = max(min(output_r, 145), 0);
break;
default:
wprintf(L"Usage: %s [options]\n\n", argv[0]);
wprintf(L" -e - Enumerate available devices\n");
wprintf(L" -i - Init device\n");
wprintf(L" -i - Enable headphone\n");
wprintf(L" -d - Set default values\n");
wprintf(L" -c <name> - Set input channel ('mic', 'hiz', 'line', 'mic_hiz', 'mute')\n");
wprintf(L" -M - Input monitoring on\n");
wprintf(L" -m - Input monitoring off\n");
wprintf(L" -l <0-255> - Input left volume\n");
wprintf(L" -r <0-255> - Input right volume\n");
wprintf(L" -L <0-255> - Output left volume\n");
wprintf(L" -R <0-255> - Output right volume\n");
wprintf(L" -l <0-127> - Input left volume\n");
wprintf(L" -r <0-127> - Input right volume\n");
wprintf(L" -L <0-145> - Output left volume\n");
wprintf(L" -R <0-145> - Output right volume\n");
exit(0);
}
}
Expand All @@ -154,7 +157,7 @@ int main(int argc, char *argv[])
hiddev = hid_open(VENDOR_ID, PRODUCT_ID, NULL);
if( hiddev != NULL ) {
if( do_i ) {
wprintf(L" Init device\n");
wprintf(L" Enable headphone\n");
send(hiddev, 0x1a, 0x00);
}
if( do_c ) {
Expand All @@ -167,19 +170,19 @@ int main(int argc, char *argv[])
}
if( do_l ) {
wprintf(L" Set input left volume: %d\n", input_l);
send(hiddev, 0x1c, input_l);
send(hiddev, 0x1c, input_l + 104); // 104 - min value
}
if( do_r ) {
wprintf(L" Set input right volume: %d\n", input_r);
send(hiddev, 0x1e, input_r);
send(hiddev, 0x1e, input_r + 104); // 104 - min value
}
if( do_L ) {
wprintf(L" Set output left volume: %d\n", output_l);
send(hiddev, 0x07, output_l);
send(hiddev, 0x07, output_l + 110); // 110 - min value
}
if( do_R ) {
wprintf(L" Set output right volume: %d\n", output_r);
send(hiddev, 0x09, output_r);
send(hiddev, 0x09, output_r + 110); // 110 - min value
}
hid_close(hiddev);
} else
Expand Down

0 comments on commit 74b543c

Please sign in to comment.