#include "kds_s2000w_handler_opts.h"
 #include "kds_s2000w_debug.h"
 
-#define COUNT_CUSTOM_OPTIONS 7
+#define COUNT_CUSTOM_OPTIONS 8
 
 extern response* resp;
 extern json_object* resp_config;
                        memcpy(value, &gamma_table[0][0], sizeof(int) * 256);
                        break;
                case 27:
-                       memcpy(value, &gamma_table[0][1], sizeof(int) * 256);
+                       memcpy(value, &gamma_table[1][0], sizeof(int) * 256);
                        break;
                case 28:
-                       memcpy(value, &gamma_table[0][2], sizeof(int) * 256);
+                       memcpy(value, &gamma_table[2][0], sizeof(int) * 256);
                        break;
                case 29:
-                       memcpy(value, &gamma_table[0][3], sizeof(int) * 256);
+                       memcpy(value, &gamma_table[3][0], sizeof(int) * 256);
                        break;
                default:
                        break;
 
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        constraint_gamma_range_r = malloc(sizeof(SANE_Range));
-       constraint_gamma_range->min = 0;
-       constraint_gamma_range->max = 255;
-       constraint_gamma_range->quant = 1;
+       constraint_gamma_range_r->min = 0;
+       constraint_gamma_range_r->max = 255;
+       constraint_gamma_range_r->quant = 0;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
        descriptor->constraint.range = constraint_gamma_range_r;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        constraint_gamma_range_g = malloc(sizeof(SANE_Range));
-       constraint_gamma_range->min = 0;
-       constraint_gamma_range->max = 255;
-       constraint_gamma_range->quant = 0;
+       constraint_gamma_range_g->min = 0;
+       constraint_gamma_range_g->max = 255;
+       constraint_gamma_range_g->quant = 0;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
        descriptor->constraint.range = constraint_gamma_range_g;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
        constraint_gamma_range_b = malloc(sizeof(SANE_Range));
-       constraint_gamma_range->min = 0;
-       constraint_gamma_range->max = 255;
-       constraint_gamma_range->quant = 0;
+       constraint_gamma_range_b->min = 0;
+       constraint_gamma_range_b->max = 255;
+       constraint_gamma_range_b->quant = 0;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
        descriptor->constraint.range = constraint_gamma_range_b;