Beispiel #1
0
int16_t mixer_get_curve_val(uint8_t curve, int16_t input)
{
	int16_t xa, xb;
	int16_t ya, yb;
	int32_t y;

	// Limit...
	if (input < -100)
	{
		input = -100;
	}
	if (input > 100)
	{
		input = 100;
	}

	// What segment	of the curve?
	if (input <= -50)
	{
		// [-100..-50]
		ya = CURVE(0, curve);
		yb = CURVE(1, curve);
		xa = -100;
		xb = -50;
	}
	else if ((input > -50) && (input <= 0))
	{
		// [-50..0]
		ya = CURVE(1, curve);
		yb = CURVE(2, curve);
		xa = -50;
		xb = 0;
	}
	else if ((input > 0) && (input <= 50))
	{
		// [0..50]
		ya = CURVE(2, curve);
		yb = CURVE(3, curve);
		xa = 0;
		xb = 50;
	}
	else if ((input > 50) && (input <= 100))
	{
		// [50..100]
		ya = CURVE(3, curve);
		yb = CURVE(4, curve);
		xa = 50;
		xb = 100;
	}
	else
	{
		// invalid...
		return 0;
	}

	// Interpolate between the points...
	y = ya + (yb - ya)*(input - xa)/(xb - xa);

	return (int16_t)y;
}
bool GuiFadeTween::update(GuiElement *element)
{
    step += proportionPerTick;
    if (step >= 1.0) {
        active = false;
    } else {
        element->set_alpha(CURVE(step,start,end));
        active = fabs(element->get_alpha()-end) > 0.05;
    }

    return active;
}
Beispiel #3
0
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
		0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
	};
	int i, j;

	/* apply mask */
	for (i = 0; i < 2; i++)
		for (j = 0; j < 10; j++)
			CURVE(i, j) &= mask[i * par->gamma.num_values + j];

	write_reg(par, 0x0030, CURVE(0, 5) << 8 | CURVE(0, 4));
	write_reg(par, 0x0031, CURVE(0, 7) << 8 | CURVE(0, 6));
	write_reg(par, 0x0032, CURVE(0, 9) << 8 | CURVE(0, 8));
	write_reg(par, 0x0035, CURVE(0, 3) << 8 | CURVE(0, 2));
	write_reg(par, 0x0036, CURVE(0, 1) << 8 | CURVE(0, 0));

	write_reg(par, 0x0037, CURVE(1, 5) << 8 | CURVE(1, 4));
	write_reg(par, 0x0038, CURVE(1, 7) << 8 | CURVE(1, 6));
	write_reg(par, 0x0039, CURVE(1, 9) << 8 | CURVE(1, 8));
	write_reg(par, 0x003C, CURVE(1, 3) << 8 | CURVE(1, 2));
	write_reg(par, 0x003D, CURVE(1, 1) << 8 | CURVE(1, 0));

	return 0;
}
Beispiel #4
0
static int gamma_adj(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
		0x1f, 0x3f, 0x0f, 0x0f, 0x7f, 0x1f,
		0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
	int i, j;

	fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);

	for (i = 0; i < GAMMA_NUM; i++)
		for (j = 0; j < GAMMA_LEN; j++)
			CURVE(i, j) &= mask[i*par->gamma.num_values + j];

	write_reg(par, CMD_PGAMMAC,
				CURVE(0, 0),
				CURVE(0, 1),
				CURVE(0, 2),
				CURVE(0, 3),
				CURVE(0, 4),
				CURVE(0, 5),
				CURVE(0, 6),
				(CURVE(0, 7) << 4) | CURVE(0, 8),
				CURVE(0, 9),
				CURVE(0, 10),
				CURVE(0, 11),
				CURVE(0, 12),
				CURVE(0, 13),
				CURVE(0, 14),
				CURVE(0, 15)
				);

	write_reg(par, CMD_RAMWR); /* Write Data to GRAM mode */

	return 0;
}
Beispiel #5
0
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0x0f, 0x0f, 0x1f, 0x0f, 0x0f, 0x0f, 0x1f, 0x07, 0x07, 0x07,
		0x07, 0x07, 0x07, 0x03, 0x03, 0x0f, 0x0f, 0x1f, 0x0f, 0x0f,
		0x0f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00,
	};
	int i, j;

	/* apply mask */
	for (i = 0; i < par->gamma.num_curves; i++)
		for (j = 0; j < par->gamma.num_values; j++)
			CURVE(i, j) &= mask[i * par->gamma.num_values + j];

	/* Gamma Set (26h) */
	write_reg(par, MIPI_DCS_SET_GAMMA_CURVE, 1 << CURVE(1, 14));

	if (CURVE(1, 14))
		return 0; /* only GC0 can be customized */

	write_reg(par, 0xC2,
		  (CURVE(0, 8) << 4) | CURVE(0, 7),
		  (CURVE(0, 10) << 4) | CURVE(0, 9),
		  (CURVE(0, 12) << 4) | CURVE(0, 11),
		  CURVE(0, 2),
		  (CURVE(0, 4) << 4) | CURVE(0, 3),
		  CURVE(0, 5),
		  CURVE(0, 6),
		  (CURVE(0, 1) << 4) | CURVE(0, 0),
		  (CURVE(0, 14) << 2) | CURVE(0, 13));

	write_reg(par, 0xC3,
		  (CURVE(1, 8) << 4) | CURVE(1, 7),
		  (CURVE(1, 10) << 4) | CURVE(1, 9),
		  (CURVE(1, 12) << 4) | CURVE(1, 11),
		  CURVE(1, 2),
		  (CURVE(1, 4) << 4) | CURVE(1, 3),
		  CURVE(1, 5),
		  CURVE(1, 6),
		  (CURVE(1, 1) << 4) | CURVE(1, 0));

	mdelay(10);

	return 0;
}
Beispiel #6
0
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0b11111, 0b11111, 0b111, 0b111, 0b111,
		0b111, 0b111, 0b111, 0b111, 0b111,
		0b11111, 0b11111, 0b111, 0b111, 0b111,
		0b111, 0b111, 0b111, 0b111, 0b111 };
	int i, j;

	fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);

	/* apply mask */
	for (i = 0; i < 2; i++)
		for (j = 0; j < 10; j++)
			CURVE(i, j) &= mask[i*par->gamma.num_values + j];

	write_reg(par, 0x0030, CURVE(0, 5) << 8 | CURVE(0, 4));
	write_reg(par, 0x0031, CURVE(0, 7) << 8 | CURVE(0, 6));
	write_reg(par, 0x0032, CURVE(0, 9) << 8 | CURVE(0, 8));
	write_reg(par, 0x0035, CURVE(0, 3) << 8 | CURVE(0, 2));
	write_reg(par, 0x0036, CURVE(0, 1) << 8 | CURVE(0, 0));

	write_reg(par, 0x0037, CURVE(1, 5) << 8 | CURVE(1, 4));
	write_reg(par, 0x0038, CURVE(1, 7) << 8 | CURVE(1, 6));
	write_reg(par, 0x0039, CURVE(1, 9) << 8 | CURVE(1, 8));
	write_reg(par, 0x003C, CURVE(1, 3) << 8 | CURVE(1, 2));
	write_reg(par, 0x003D, CURVE(1, 1) << 8 | CURVE(1, 0));

	return 0;
}
Beispiel #7
0
static int gamma_adj(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
		0x1f, 0x3f, 0x0f, 0x0f, 0x7f, 0x1f,
		0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
	int i, j;

	for (i = 0; i < GAMMA_NUM; i++)
		for (j = 0; j < GAMMA_LEN; j++)
			CURVE(i, j) &= mask[i * par->gamma.num_values + j];

	write_reg(par, CMD_PGAMMAC,
		  CURVE(0, 0),
		  CURVE(0, 1),
		  CURVE(0, 2),
		  CURVE(0, 3),
		  CURVE(0, 4),
		  CURVE(0, 5),
		  CURVE(0, 6),
		  (CURVE(0, 7) << 4) | CURVE(0, 8),
		  CURVE(0, 9),
		  CURVE(0, 10),
		  CURVE(0, 11),
		  CURVE(0, 12),
		  CURVE(0, 13),
		  CURVE(0, 14),
		  CURVE(0, 15));

	/* Write Data to GRAM mode */
	write_reg(par, MIPI_DCS_WRITE_MEMORY_START);

	return 0;
}
Beispiel #8
0
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{
    int i;

    fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);

    for (i = 0; i < par->gamma.num_curves; i++)
        write_reg(par, 0xE0 + i,
                  CURVE(i, 0), CURVE(i, 1), CURVE(i, 2),
                  CURVE(i, 3), CURVE(i, 4), CURVE(i, 5),
                  CURVE(i, 6), CURVE(i, 7), CURVE(i, 8),
                  CURVE(i, 9), CURVE(i, 10), CURVE(i, 11),
                  CURVE(i, 12), CURVE(i, 13), CURVE(i, 14));

    return 0;
}
Beispiel #9
0
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{
	unsigned long mask[] = {
		0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
		0b1111111, 0b1111111,
		0b11111, 0b11111, 0b11111, 0b11111, 0b11111,
		0b1111};
	int i, j;
	int acc = 0;

	fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);

	/* apply mask */
	for (i = 0; i < par->gamma.num_curves; i++)
		for (j = 0; j < par->gamma.num_values; j++) {
			acc += CURVE(i, j);
			CURVE(i, j) &= mask[j];
		}

	if (acc == 0) /* skip if all values are zero */
		return 0;

	for (i = 0; i < par->gamma.num_curves; i++) {
		write_reg(par, 0x40 + (i * 0x10), CURVE(i, 0));
		write_reg(par, 0x41 + (i * 0x10), CURVE(i, 1));
		write_reg(par, 0x42 + (i * 0x10), CURVE(i, 2));
		write_reg(par, 0x43 + (i * 0x10), CURVE(i, 3));
		write_reg(par, 0x44 + (i * 0x10), CURVE(i, 4));
		write_reg(par, 0x45 + (i * 0x10), CURVE(i, 5));
		write_reg(par, 0x46 + (i * 0x10), CURVE(i, 6));
		write_reg(par, 0x47 + (i * 0x10), CURVE(i, 7));
		write_reg(par, 0x48 + (i * 0x10), CURVE(i, 8));
		write_reg(par, 0x49 + (i * 0x10), CURVE(i, 9));
		write_reg(par, 0x4A + (i * 0x10), CURVE(i, 10));
		write_reg(par, 0x4B + (i * 0x10), CURVE(i, 11));
		write_reg(par, 0x4C + (i * 0x10), CURVE(i, 12));
	}
	write_reg(par, 0x5D, (CURVE(1, 0) << 4) | CURVE(0, 0));

	return 0;
}