/**
 * Set breath effect on the keyboard
 *
 * Breathing types
 * 1: Only 1 Colour
 * 2: 2 Colours
 * 3: Random
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 *
 */
int razer_set_breath_mode(struct usb_device *usb_dev, unsigned char breathing_type, struct razer_rgb *color1, struct razer_rgb *color2)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x08;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT;
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_BREATH;

    report.command_parameters[0] = breathing_type;

    if(breathing_type == 1 || breathing_type == 2)
    {
        // Colour 1
        report.command_parameters[1] = color1->r;
        report.command_parameters[2] = color1->g;
        report.command_parameters[3] = color1->b;
    }

    if(breathing_type == 2)
    {
        // Colour 2
        report.command_parameters[4] = color2->r;
        report.command_parameters[5] = color2->g;
        report.command_parameters[6] = color2->b;
    }

    //printk(KERN_WARNING "razerkbd: Breath C1: %02x%02x%02x, C2: %02x%02x%02x", color1->r, color1->g, color1->b, color2->r, color2->g, color2->b);

    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
int razer_set_key_row(struct usb_device *usb_dev,unsigned char row_index,struct razer_row_rgb *row_cols)
{
    //sets the whole row at once -> old values need to be buffered or read from device    printk(KERN_ALERT "setting mode to: Set Keys\n");    
    //0 1=ESC 3=F1 PAUSE=17 20=LOGO
    //1 0=M1 MINUS=21
    //2 = 21
    //3 = 20
    //4 = 21
    //5 = 20 4,5,6,7,8,9,10,12=UNUSED
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x46;
    report.command = 0x0B; /*set keys command id*/
    report.sub_command = 0xFF;/*set keys mode id*/
    report.command_parameters[0] = row_index; /*row number*/
    report.command_parameters[1] = 0x0; /*unknown always 0*/
    report.command_parameters[2] = 0x15; /*number of keys in row always 21*/
    memcpy(&report.command_parameters[3],row_cols,sizeof(struct razer_row_rgb));
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
/**
 * Set spectrum effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_spectrum_mode(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x01;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_SPECTRUM;/*spectrum mode id*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
Exemplo n.º 4
0
/**
 * Set the wave effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Ultimate 2016
 */
int razer_set_starlight_mode(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x01;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT;   /* Change effect command ID */
    report.sub_command = RAZER_BLACKWIDOW_ULTIMATE_2016_EFFECT_STARLIGHT; /* Wave mode ID */
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
/**
 * Set custom effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_custom_mode(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x02;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_CUSTOM;/*custom mode id*/
    report.command_parameters[0] = 0x01; /*profile index? active ?*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
/**
 * Clear row on the keyboard
 *
 * Clears a row's colour on the keyboard. Rows range from 0-5, 0 being the top row with escape
 * and 5 being the last row with the spacebar
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_temp_clear_row(struct usb_device *usb_dev, unsigned char row_index)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x02;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_CLEAR_ROW;/*clear_row mode id*/
    report.command_parameters[0] = row_index; /*line number starting from top*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
int razer_activate_macro_keys(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 2;
    report.command = 0x4; /*reset command id*/
    report.reserved2 = 0x0;
    report.sub_command = 0x02;/*unknown*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    return retval;
}
/**
 * Set the wave effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_wave_mode(struct usb_device *usb_dev, unsigned char direction)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x02;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT;   /* Change effect command ID */
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_WAVE; /* Wave mode ID */
    report.command_parameters[0] = direction;                 /* Direction 2=Left / 1=Right */
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
/**
 * Set static effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Ultimate 2013
 */
int razer_set_static_mode_blackwidow_ultimate(struct usb_device *usb_dev)
{
    int retval = 0;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x03;
    report.command = 0x02;
    report.sub_command = 0x01;
    report.command_parameters[0] = 0x04;
    report.command_parameters[1] = 0x00;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
Exemplo n.º 10
0
/**
 * Reset the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 *   Razer BlackWidow Ultimate 2013
 */
int razer_reset(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x03;
    report.command = 0x00; /*reset command id*/
    report.sub_command = 0x01;/*unknown*/
    report.command_parameters[0] = 0x08;/*unknown*/
    report.command_parameters[1] = 0x00;/*unknown*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
int razer_test(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 2;
    report.command = 0x0; /*init command id ?*/
    report.sub_command = 0x04;/*unknown*/
    //report.command_parameters[0] = 8;/*unknown*/
    //report.command_parameters[1] = 0;/*unknown*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    return retval;
}
int razer_set_brightness(struct usb_device *usb_dev,unsigned char brightness)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 3;
    report.command = 0x3; /*set brightness command id*/
    report.sub_command = 0x01;/*unknown*/
    report.command_parameters[0] = 5;/*unknown (not speed)*/
    report.command_parameters[1] = brightness;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    return retval;
}
Exemplo n.º 13
0
/**
 * Change the effect on the keyboard
 *
 * Currently contains unknown commands
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
void razer_change_effect(struct usb_device *usb_dev, uint effect_id)
{
    struct razer_report report;
    razer_prepare_report(&report);

    switch(effect_id)
    {
        case RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN3:
            printk(KERN_ALERT "setting mode to: Unknown3\n");//most likely stats profile change    
            report.parameter_bytes_num = 0x03;
            report.command = 0x01; /*reset command id*/
            report.sub_command = 0x05;/*unknown*/
            report.command_parameters[0] = 0xFF;/*unknown*/
            report.command_parameters[0] = 0x01;/*unknown*/
            report.crc = razer_calculate_crc(&report);
            razer_send_report(usb_dev, &report);
            break;
        case RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN:
            printk(KERN_ALERT "setting mode to: Unknown\n");//most likely stats profile change    
            report.parameter_bytes_num = 0x03;
            report.command = 0x02; /*reset command id*/
            report.sub_command = 0x00;/*unknown*/
            report.command_parameters[0] = 0x07;/*unknown*/
            report.command_parameters[1] = 0x00;/*unknown*/
            report.crc = razer_calculate_crc(&report);
            razer_send_report(usb_dev, &report);
            break;
        case RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN2:
            printk(KERN_ALERT "setting mode to: Unknown2\n");    
            report.parameter_bytes_num = 0x03;
            report.command = 0x00; /*reset command id*/
            report.sub_command = 0x00;/*unknown*/
            report.command_parameters[0] = 0x07;/*unknown*/
            report.command_parameters[1] = 0x00;/*unknown*/
            report.crc = razer_calculate_crc(&report);
            razer_send_report(usb_dev, &report);
            break;
        case RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN4:
            printk(KERN_ALERT "setting mode to: Unknown4\n");    
            report.parameter_bytes_num = 0x03;
            report.command = 0x00; /*reset command id*/
            report.sub_command = 0x01;/*unknown*/
            report.command_parameters[0] = 0x05;/*unknown*/
            report.command_parameters[1] = 0x01;/*unknown*/
            report.crc = razer_calculate_crc(&report);
            razer_send_report(usb_dev, &report);
            break;
            //1,8,0 
    }
}
Exemplo n.º 14
0
/**
 * Set static effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_static_mode(struct usb_device *usb_dev, struct razer_rgb *color)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x04;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_STATIC;/*static mode id*/
    report.command_parameters[0] = color->r; /*rgb color definition*/
    report.command_parameters[1] = color->g;
    report.command_parameters[2] = color->b;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
int razer_set_none_mode(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 1;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = 0;/*none mode id*/
    //report.command_parameters[0] = 0x01; /*profile index? active ?*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
int razer_set_wave_mode(struct usb_device *usb_dev,unsigned char direction)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 2;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_WAVE;/*wave mode id*/
    report.command_parameters[0] = direction;/*direction 2=left / 1=right*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
int razer_activate_macro_keys(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 2;
    report.command = 0x4; /*reset command id*/
    report.reserved2 = 0x0;
    report.sub_command = 0x02;/*unknown*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
int razer_set_reactive_mode(struct usb_device *usb_dev,struct razer_rgb *color,unsigned char speed)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 5;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_REACTIVE;/*reactive mode id*/
    report.command_parameters[0] = speed;/*identified by Oleg Finkelshteyn*/
    report.command_parameters[1] = color->r; /*rgb color definition*/
    report.command_parameters[2] = color->g;
    report.command_parameters[3] = color->b;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    return retval;
}
Exemplo n.º 19
0
/**
 * Set row colour on the keyboard
 *
 * This sets the colour of a row on the keyboard. Takes in an array of RGB bytes.
 * The mappings below are correct for the BlackWidow Chroma. The BlackWidow Ultimate 2016
 * contains LEDs under the spacebar and the FN key so there will be changes once I get the
 * hardware.
 *
 * Row 0:
 *  0      Unused
 *  1      ESC
 *  2      Unused
 *  3-14   F1-F12
 *  15-17  PrtScr, ScrLk, Pause
 *  18-19  Unused
 *  20     Razer Logo
 *  21     Unused
 *
 * Row 1:
 *  0-21   M1 -> NP Minus
 *
 * Row 2:
 *  0-13   M2 -> Right Square Bracket ]
 *  14 Unused
 *  15-21 Delete -> NP Plus
 *
 * Row 3:
 *  0-14   M3 -> Return
 *  15-17  Unused
 *  18-20  NP4 -> NP6
 *
 * Row 4:
 *  0-12   M4 -> Forward Slash /
 *  13     Unused
 *  14     Right Shift
 *  15     Unused
 *  16     Up Arrow Key
 *  17     Unused
 *  18-21  NP1 -> NP Enter
 *
 * Row 5:
 *  0-3    M5 -> Alt
 *  4-10   Unused
 *  11     Alt GR
 *  12     Unused
 *  13-17  Context Menu Key -> Right Arrow Key
 *  18     Unused
 *  19-20  NP0 -> NP.
 *  21     Unused
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_key_row(struct usb_device *usb_dev, unsigned char row_index, unsigned char *row_cols) //struct razer_row_rgb *row_cols)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = RAZER_BLACKWIDOW_CHROMA_ROW_LEN * 3 + 4;
    report.command = 0x0B; /*set keys command id*/
    report.sub_command = 0xFF;/*set keys mode id*/
    report.command_parameters[0] = row_index; /*row number*/
    report.command_parameters[1] = 0x00; /*unknown always 0*/
    report.command_parameters[2] = RAZER_BLACKWIDOW_CHROMA_ROW_LEN - 1; /*number of keys in row always 21*/
    memcpy(&report.command_parameters[3], row_cols, (report.command_parameters[2]+1)*3);
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
Exemplo n.º 20
0
/**
 * Set custom effect on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 *   Razer BlackWidow Ultimate 2016 (Not working :( )
 */
int razer_set_custom_mode(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x02;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_CUSTOM;/*custom mode id*/
    report.command_parameters[0] = 0x01; /*profile index? active ?*/
    if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2016)
    {
		report.command_parameters[0] = 0x00; /*profile index? active ?*/
	}
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}
int razer_reset(struct usb_device *usb_dev)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 3;
    report.command = 0x0; /*reset command id*/
    report.sub_command = 0x01;/*unknown*/
    report.command_parameters[0] = 8;/*unknown*/
    report.command_parameters[1] = 0;/*unknown*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
int razer_set_brightness(struct usb_device *usb_dev,unsigned char brightness)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 3;
    report.command = 0x3; /*set brightness command id*/
    report.sub_command = 0x01;/*unknown*/
    report.command_parameters[0] = 5;/*unknown*/
    report.command_parameters[1] = brightness;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
int razer_set_reactive_mode(struct usb_device *usb_dev,struct razer_rgb *color)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 5;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_REACTIVE;/*reactive mode id*/
    report.command_parameters[0] = 3;/*num of rgb bytes ?*/
    report.command_parameters[1] = color->r; /*rgb color definition*/
    report.command_parameters[2] = color->g;
    report.command_parameters[3] = color->b;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
Exemplo n.º 24
0
/**
 * Set game mode on the keyboard
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 *   Razer BlackWidow Ultimate 2013
 */
int razer_set_game_mode(struct usb_device *usb_dev, unsigned char enable)
{
    int retval = 0;
    if(enable > 1)
    {
        printk(KERN_WARNING "razerkbd: Cannot set game mode to %d. Only 1 or 0 allowed.", enable);
    } else
    {
        struct razer_report report;
        razer_prepare_report(&report);
        report.parameter_bytes_num = 0x03;
        report.command = 0x00;
        report.sub_command = 0x01;
        report.command_parameters[0] = 0x08;
        report.command_parameters[1] = enable;
        report.crc = razer_calculate_crc(&report);
        retval = razer_send_report(usb_dev, &report);
    }
    return retval;
}
int razer_set_breath_mode(struct usb_device *usb_dev,struct razer_rgb *colors,unsigned char num_cols) //num_cols ? really ??
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    //report.parameter_bytes_num = (sizeof(struct razer_rgb)*num_cols)+1;
    report.parameter_bytes_num = 8;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_BREATH;/*breath mode id*/
    report.command_parameters[0] = num_cols;
    memcpy(&report.command_parameters[1],colors,sizeof(struct razer_rgb)*num_cols);
    /*report.command_parameters[1] = first_color->r; //first rgb color definition
    report.command_parameters[2] = first_color->g;
    report.command_parameters[3] = first_color->b;
    report.command_parameters[4] = second_color->r; //second rgb color definition
    report.command_parameters[5] = second_color->g;
    report.command_parameters[6] = second_color->b;*/
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    return retval;
}
int razer_set_breath_mode(struct usb_device *usb_dev,struct razer_rgb *first_color,struct razer_rgb *second_color)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 8;
    report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
    report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_BREATH;/*breath mode id*/
    report.command_parameters[0] = 2;/*num of cols ?*/
    report.command_parameters[1] = first_color->r; /*first rgb color definition*/
    report.command_parameters[2] = first_color->g;
    report.command_parameters[3] = first_color->b;
    report.command_parameters[4] = second_color->r; /*second rgb color definition*/
    report.command_parameters[5] = second_color->g;
    report.command_parameters[6] = second_color->b;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev,&report);
    //msleep(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //mdelay(RAZER_BLACKWIDOW_CHROMA_WAIT_MS);
    //usleep_range(300,600);
    return retval;
}
Exemplo n.º 27
0
/**
 * Set reactive effect on the keyboard
 *
 * The speed must be within 01-03
 *
 * 1 Short, 2 Medium, 3 Long
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 */
int razer_set_reactive_mode(struct usb_device *usb_dev, struct razer_rgb *color, unsigned char speed)
{
    int retval = 0;
    if(speed > 0 && speed < 4)
    {
        struct razer_report report;
        razer_prepare_report(&report);
        report.parameter_bytes_num = 0x05;
        report.command = RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT; /*change effect command id*/
        report.sub_command = RAZER_BLACKWIDOW_CHROMA_EFFECT_REACTIVE;/*reactive mode id*/
        report.command_parameters[0] = speed;/*identified by Oleg Finkelshteyn*/
        report.command_parameters[1] = color->r; /*rgb color definition*/
        report.command_parameters[2] = color->g;
        report.command_parameters[3] = color->b;
        report.crc = razer_calculate_crc(&report);
        retval = razer_send_report(usb_dev, &report);
    } else
    {
        printk(KERN_WARNING "razerkbd: Reactive mode, Speed must be within 1-3. Got: %d", speed);
    }
    return retval;
}
Exemplo n.º 28
0
/**
 * Get the devices serial number
 *
 * Makes a request like normal, this must change a variable in the mouse as then we
 * tell it give us data (same request for get_battery in the mouse driver) and it 
 * gives us a report.
 *
 * Supported Devices:
 *   Razer Chroma
 *   Razer BlackWidow Ultimate 2013*
 * 
 * *Untested but should work
 */
void razer_get_serial(struct usb_device *usb_dev, unsigned char* serial_string)
{
    struct razer_report response_report;
    struct razer_report request_report;
    int retval;
    int i;

    razer_prepare_report(&request_report);

    request_report.parameter_bytes_num = 0x16;
    request_report.reserved2 = 0x00;
    request_report.command = 0x82;
    request_report.sub_command = 0x00;
    request_report.command_parameters[0] = 0x00;
    request_report.crc = razer_calculate_crc(&request_report);


    retval = razer_get_usb_response(usb_dev, 0x01, &request_report, 0x01, &response_report, RAZER_BLACKWIDOW_CHROMA_WAIT_MIN_US, RAZER_BLACKWIDOW_CHROMA_WAIT_MAX_US);

    if(retval == 0)
    {
        if(response_report.report_start_marker == 0x02 && response_report.reserved2 == 0x00 && response_report.command == 0x82)
        {
            unsigned char* pointer = &response_report.sub_command;
            for(i = 0; i < 20; ++i)
            {
                serial_string[i] = *pointer;
                ++pointer;
            }
        } else
        {
            print_erroneous_report(&response_report, "razerkbd", "Invalid Report Type");
        }
    } else
    {
      print_erroneous_report(&response_report, "razerkbd", "Invalid Report Length");
    }
}
Exemplo n.º 29
0
/**
 * Set the keyboard brightness
 *
 * Supported by:
 *   Razer BlackWidow Chroma
 *   Razer BlackWidow Ultimate 2013
 */
int razer_set_brightness(struct usb_device *usb_dev, unsigned char brightness)
{
    int retval;
    struct razer_report report;
    razer_prepare_report(&report);
    report.parameter_bytes_num = 0x03;
    report.command = 0x03; /*set brightness command id*/
    report.sub_command = 0x01;/*unknown*/

    if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2013)
    {
        report.command_parameters[0] = 0x04;/*unknown (not speed)*/
    } else if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA)
    {
        report.command_parameters[0] = 0x05;/*unknown (not speed)*/
    } else {
        printk(KERN_WARNING "razerkbd: Unknown product ID '%d'", usb_dev->descriptor.idProduct);
    }

    report.command_parameters[1] = brightness;
    report.crc = razer_calculate_crc(&report);
    retval = razer_send_report(usb_dev, &report);
    return retval;
}