diff options
Diffstat (limited to 'drivers/staging/fbtft')
24 files changed, 186 insertions, 146 deletions
diff --git a/drivers/staging/fbtft/fb_hx8347d.c b/drivers/staging/fbtft/fb_hx8347d.c index 0b605303813e..3427a858d17c 100644 --- a/drivers/staging/fbtft/fb_hx8347d.c +++ b/drivers/staging/fbtft/fb_hx8347d.c @@ -92,7 +92,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) * VRP0 VRP1 VRP2 VRP3 VRP4 VRP5 PRP0 PRP1 PKP0 PKP1 PKP2 PKP3 PKP4 CGM * VRN0 VRN1 VRN2 VRN3 VRN4 VRN5 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 CGM */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c index fd3dd671509f..86e140244aab 100644 --- a/drivers/staging/fbtft/fb_ili9163.c +++ b/drivers/staging/fbtft/fb_ili9163.c @@ -192,7 +192,7 @@ static int set_var(struct fbtft_par *par) } #ifdef GAMMA_ADJ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int gamma_adj(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c index 501eee7dce4c..740c0acbecd8 100644 --- a/drivers/staging/fbtft/fb_ili9320.c +++ b/drivers/staging/fbtft/fb_ili9320.c @@ -211,7 +211,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 RP0 RP1 KP0 KP1 KP2 KP3 KP4 KP5 * VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9325.c b/drivers/staging/fbtft/fb_ili9325.c index d6b1d4be9ff4..2cf75f2e03e2 100644 --- a/drivers/staging/fbtft/fb_ili9325.c +++ b/drivers/staging/fbtft/fb_ili9325.c @@ -205,7 +205,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 RP0 RP1 KP0 KP1 KP2 KP3 KP4 KP5 * VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { diff --git a/drivers/staging/fbtft/fb_ili9341.c b/drivers/staging/fbtft/fb_ili9341.c index a10e8c9de438..9ccd0823c3ab 100644 --- a/drivers/staging/fbtft/fb_ili9341.c +++ b/drivers/staging/fbtft/fb_ili9341.c @@ -111,7 +111,7 @@ static int set_var(struct fbtft_par *par) * Positive: Par1 Par2 [...] Par15 * Negative: Par1 Par2 [...] Par15 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { int i; diff --git a/drivers/staging/fbtft/fb_s6d02a1.c b/drivers/staging/fbtft/fb_s6d02a1.c index 75295760f491..d3d6871d8c47 100644 --- a/drivers/staging/fbtft/fb_s6d02a1.c +++ b/drivers/staging/fbtft/fb_s6d02a1.c @@ -16,25 +16,31 @@ #define DRVNAME "fb_s6d02a1" static const s16 default_init_sequence[] = { - -1, 0xf0, 0x5a, 0x5a, -1, 0xfc, 0x5a, 0x5a, - -1, 0xfa, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, + -1, 0xfa, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, + 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, - -1, 0xfb, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, + -1, 0xfb, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, + 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, /* power setting sequence */ - -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, 0x01, 0x00, 0x1f, 0x1f, + -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, + 0x01, 0x00, 0x1f, 0x1f, - -1, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, - -1, 0xf5, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, + -1, 0xf5, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, - -1, 0xf6, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x01, 0x00, + -1, 0xf6, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x06, 0x01, 0x00, - -1, 0xf2, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, + -1, 0xf2, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, -1, 0xf8, 0x11, @@ -54,7 +60,8 @@ static const s16 default_init_sequence[] = { -1, 0xf3, 0x00, 0x0f, -2, 50, - -1, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, -2, 50, -1, 0xf3, 0x00, 0x1f, @@ -65,9 +72,11 @@ static const s16 default_init_sequence[] = { -1, 0xf3, 0x00, 0xff, -2, 50, - -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, 0x01, 0x00, 0x16, 0x16, + -1, 0xfd, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, + 0x01, 0x00, 0x16, 0x16, - -1, 0xf4, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, + -1, 0xf4, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, + 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, /* initializing sequence */ diff --git a/drivers/staging/fbtft/fb_s6d1121.c b/drivers/staging/fbtft/fb_s6d1121.c index b90244259d43..aa716f33420a 100644 --- a/drivers/staging/fbtft/fb_s6d1121.c +++ b/drivers/staging/fbtft/fb_s6d1121.c @@ -120,7 +120,7 @@ static int set_var(struct fbtft_par *par) * PKP0 PKP1 PKP2 PKP3 PKP4 PKP5 PKP6 PKP7 PKP8 PKP9 PKP10 PKP11 VRP0 VRP1 * PKN0 PKN1 PKN2 PKN3 PKN4 PKN5 PKN6 PKN7 PRN8 PRN9 PRN10 PRN11 VRN0 VRN1 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { @@ -154,6 +154,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fb_sh1106.c b/drivers/staging/fbtft/fb_sh1106.c index 3fc18c0a6f11..00096f8d249a 100644 --- a/drivers/staging/fbtft/fb_sh1106.c +++ b/drivers/staging/fbtft/fb_sh1106.c @@ -89,7 +89,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); write_reg(par, on ? 0xAE : 0xAF); diff --git a/drivers/staging/fbtft/fb_ssd1289.c b/drivers/staging/fbtft/fb_ssd1289.c index cbf22e1f4b61..c9b18b3ba4ab 100644 --- a/drivers/staging/fbtft/fb_ssd1289.c +++ b/drivers/staging/fbtft/fb_ssd1289.c @@ -38,7 +38,7 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x0E, 0x2B00); write_reg(par, 0x1E, 0x00B7); write_reg(par, 0x01, - BIT(13) | (par->bgr << 11) | BIT(9) | (HEIGHT - 1)); + BIT(13) | (par->bgr << 11) | BIT(9) | (HEIGHT - 1)); write_reg(par, 0x02, 0x0600); write_reg(par, 0x10, 0x0000); write_reg(par, 0x05, 0x0000); @@ -98,8 +98,8 @@ static int set_var(struct fbtft_par *par) if (par->fbtftops.init_display != init_display) { /* don't risk messing up register 11h */ fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "%s: skipping since custom init_display() is used\n", - __func__); + "%s: skipping since custom init_display() is used\n", + __func__); return 0; } @@ -126,7 +126,7 @@ static int set_var(struct fbtft_par *par) * VRP0 VRP1 PRP0 PRP1 PKP0 PKP1 PKP2 PKP3 PKP4 PKP5 * VRN0 VRN1 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 PKN5 */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { unsigned long mask[] = { @@ -153,6 +153,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fb_ssd1306.c b/drivers/staging/fbtft/fb_ssd1306.c index 9276be499303..50172ddd94ae 100644 --- a/drivers/staging/fbtft/fb_ssd1306.c +++ b/drivers/staging/fbtft/fb_ssd1306.c @@ -148,7 +148,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) diff --git a/drivers/staging/fbtft/fb_ssd1325.c b/drivers/staging/fbtft/fb_ssd1325.c index 1a469b3c92d4..f974f7fc4d79 100644 --- a/drivers/staging/fbtft/fb_ssd1325.c +++ b/drivers/staging/fbtft/fb_ssd1325.c @@ -88,7 +88,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) diff --git a/drivers/staging/fbtft/fb_ssd1331.c b/drivers/staging/fbtft/fb_ssd1331.c index 383e197cf56a..0b614c84822e 100644 --- a/drivers/staging/fbtft/fb_ssd1331.c +++ b/drivers/staging/fbtft/fb_ssd1331.c @@ -168,7 +168,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) write_reg(par, 0xAE); diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c index b8ef75f5e856..3da091b4d297 100644 --- a/drivers/staging/fbtft/fb_ssd1351.c +++ b/drivers/staging/fbtft/fb_ssd1351.c @@ -126,36 +126,44 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) for (i = 0; i < 63; i++) { if (i > 0 && curves[i] < 2) { dev_err(par->info->device, - "Illegal value in Grayscale Lookup Table at index %d. " \ - "Must be greater than 1\n", i); + "Illegal value in Grayscale Lookup Table at index %d : %d. Must be greater than 1\n", + i, curves[i]); return -EINVAL; } acc += curves[i]; tmp[i] = acc; if (acc > 180) { dev_err(par->info->device, - "Illegal value(s) in Grayscale Lookup Table. " \ - "At index=%d, the accumulated value has exceeded 180\n", i); + "Illegal value(s) in Grayscale Lookup Table. At index=%d : %d, the accumulated value has exceeded 180\n", + i, acc); return -EINVAL; } } write_reg(par, 0xB8, - tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], - tmp[8], tmp[9], tmp[10], tmp[11], tmp[12], tmp[13], tmp[14], tmp[15], - tmp[16], tmp[17], tmp[18], tmp[19], tmp[20], tmp[21], tmp[22], tmp[23], - tmp[24], tmp[25], tmp[26], tmp[27], tmp[28], tmp[29], tmp[30], tmp[31], - tmp[32], tmp[33], tmp[34], tmp[35], tmp[36], tmp[37], tmp[38], tmp[39], - tmp[40], tmp[41], tmp[42], tmp[43], tmp[44], tmp[45], tmp[46], tmp[47], - tmp[48], tmp[49], tmp[50], tmp[51], tmp[52], tmp[53], tmp[54], tmp[55], - tmp[56], tmp[57], tmp[58], tmp[59], tmp[60], tmp[61], tmp[62]); + tmp[0], tmp[1], tmp[2], tmp[3], + tmp[4], tmp[5], tmp[6], tmp[7], + tmp[8], tmp[9], tmp[10], tmp[11], + tmp[12], tmp[13], tmp[14], tmp[15], + tmp[16], tmp[17], tmp[18], tmp[19], + tmp[20], tmp[21], tmp[22], tmp[23], + tmp[24], tmp[25], tmp[26], tmp[27], + tmp[28], tmp[29], tmp[30], tmp[31], + tmp[32], tmp[33], tmp[34], tmp[35], + tmp[36], tmp[37], tmp[38], tmp[39], + tmp[40], tmp[41], tmp[42], tmp[43], + tmp[44], tmp[45], tmp[46], tmp[47], + tmp[48], tmp[49], tmp[50], tmp[51], + tmp[52], tmp[53], tmp[54], tmp[55], + tmp[56], tmp[57], tmp[58], tmp[59], + tmp[60], tmp[61], tmp[62]); return 0; } static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) write_reg(par, 0xAE); @@ -187,8 +195,8 @@ static int update_onboard_backlight(struct backlight_device *bd) bool on; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: power=%d, fb_blank=%d\n", - __func__, bd->props.power, bd->props.fb_blank); + "%s: power=%d, fb_blank=%d\n", + __func__, bd->props.power, bd->props.fb_blank); on = (bd->props.power == FB_BLANK_UNBLANK) && (bd->props.fb_blank == FB_BLANK_UNBLANK); @@ -211,7 +219,8 @@ static void register_onboard_backlight(struct fbtft_par *par) bl_props.power = FB_BLANK_POWERDOWN; bd = backlight_device_register(dev_driver_string(par->info->device), - par->info->device, par, &bl_ops, &bl_props); + par->info->device, par, &bl_ops, + &bl_props); if (IS_ERR(bd)) { dev_err(par->info->device, "cannot register backlight device (%ld)\n", diff --git a/drivers/staging/fbtft/fb_st7735r.c b/drivers/staging/fbtft/fb_st7735r.c index 631208bd3a17..9670a8989b91 100644 --- a/drivers/staging/fbtft/fb_st7735r.c +++ b/drivers/staging/fbtft/fb_st7735r.c @@ -133,7 +133,7 @@ static int set_var(struct fbtft_par *par) * VRF0P VOS0P PK0P PK1P PK2P PK3P PK4P PK5P PK6P PK7P PK8P PK9P SELV0P SELV1P SELV62P SELV63P * VRF0N VOS0N PK0N PK1N PK2N PK3N PK4N PK5N PK6N PK7N PK8N PK9N SELV0N SELV1N SELV62N SELV63N */ -#define CURVE(num, idx) curves[num * par->gamma.num_values + idx] +#define CURVE(num, idx) curves[(num) * par->gamma.num_values + (idx)] static int set_gamma(struct fbtft_par *par, u32 *curves) { int i, j; @@ -145,13 +145,18 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) 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), CURVE(i, 15)); + 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), CURVE(i, 15)); return 0; } + #undef CURVE static struct fbtft_display display = { diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c index 7d7573a7b615..3c3f387936e8 100644 --- a/drivers/staging/fbtft/fb_st7789v.c +++ b/drivers/staging/fbtft/fb_st7789v.c @@ -201,13 +201,12 @@ static int set_gamma(struct fbtft_par *par, u32 *curves) c = i * par->gamma.num_values; for (j = 0; j < par->gamma.num_values; j++) curves[c + j] &= gamma_par_mask[j]; - write_reg( - par, PVGAMCTRL + i, - curves[c + 0], curves[c + 1], curves[c + 2], - curves[c + 3], curves[c + 4], curves[c + 5], - curves[c + 6], curves[c + 7], curves[c + 8], - curves[c + 9], curves[c + 10], curves[c + 11], - curves[c + 12], curves[c + 13]); + write_reg(par, PVGAMCTRL + i, + curves[c + 0], curves[c + 1], curves[c + 2], + curves[c + 3], curves[c + 4], curves[c + 5], + curves[c + 6], curves[c + 7], curves[c + 8], + curves[c + 9], curves[c + 10], curves[c + 11], + curves[c + 12], curves[c + 13]); } return 0; } diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c index 4d65567eefe2..dfaf8bc70f73 100644 --- a/drivers/staging/fbtft/fb_uc1611.c +++ b/drivers/staging/fbtft/fb_uc1611.c @@ -129,7 +129,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) static int blank(struct fbtft_par *par, bool on) { - fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n", + fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n", __func__, on ? "true" : "false"); if (on) diff --git a/drivers/staging/fbtft/fb_watterott.c b/drivers/staging/fbtft/fb_watterott.c index bfd1527f20f7..e77178157f1b 100644 --- a/drivers/staging/fbtft/fb_watterott.c +++ b/drivers/staging/fbtft/fb_watterott.c @@ -46,7 +46,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) va_end(args); fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, - par->info->device, u8, par->buf, len, "%s: ", __func__); + par->info->device, u8, par->buf, + len, "%s: ", __func__); ret = par->fbtftops.write(par, par->buf, len); if (ret < 0) { @@ -89,9 +90,15 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) return 0; } -#define RGB565toRGB323(c) (((c&0xE000)>>8) | ((c&0600)>>6) | ((c&0x001C)>>2)) -#define RGB565toRGB332(c) (((c&0xE000)>>8) | ((c&0700)>>6) | ((c&0x0018)>>3)) -#define RGB565toRGB233(c) (((c&0xC000)>>8) | ((c&0700)>>5) | ((c&0x001C)>>2)) +#define RGB565toRGB323(c) ((((c) & 0xE000) >> 8) |\ + (((c) & 000600) >> 6) |\ + (((c) & 0x001C) >> 2)) +#define RGB565toRGB332(c) ((((c) & 0xE000) >> 8) |\ + (((c) & 000700) >> 6) |\ + (((c) & 0x0018) >> 3)) +#define RGB565toRGB233(c) ((((c) & 0xC000) >> 8) |\ + (((c) & 000700) >> 5) |\ + (((c) & 0x001C) >> 2)) static int write_vmem_8bit(struct fbtft_par *par, size_t offset, size_t len) { @@ -169,7 +176,7 @@ static int init_display(struct fbtft_par *par) version = firmware_version(par); fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "Firmware version: %x.%02x\n", - version >> 8, version & 0xFF); + version >> 8, version & 0xFF); if (mode == 332) par->fbtftops.write_vmem = write_vmem_8bit; @@ -220,9 +227,9 @@ static int backlight_chip_update_status(struct backlight_device *bd) int brightness = bd->props.brightness; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: brightness=%d, power=%d, fb_blank=%d\n", - __func__, bd->props.brightness, bd->props.power, - bd->props.fb_blank); + "%s: brightness=%d, power=%d, fb_blank=%d\n", __func__, + bd->props.brightness, bd->props.power, + bd->props.fb_blank); if (bd->props.power != FB_BLANK_UNBLANK) brightness = 0; @@ -250,7 +257,8 @@ static void register_chip_backlight(struct fbtft_par *par) bl_props.brightness = DEFAULT_BRIGHTNESS; bd = backlight_device_register(dev_driver_string(par->info->device), - par->info->device, par, &bl_ops, &bl_props); + par->info->device, par, &bl_ops, + &bl_props); if (IS_ERR(bd)) { dev_err(par->info->device, "cannot register backlight device (%ld)\n", diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c index 871b307d83cb..8ce1ff9b6c2a 100644 --- a/drivers/staging/fbtft/fbtft-bus.c +++ b/drivers/staging/fbtft/fbtft-bus.c @@ -79,7 +79,8 @@ void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...) *(((u8 *)buf) + i) = (u8)va_arg(args, unsigned int); va_end(args); fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, - par->info->device, u8, buf, len, "%s: ", __func__); + par->info->device, u8, buf, len, "%s: ", + __func__); } if (len <= 0) return; @@ -129,7 +130,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) size_t startbyte_size = 0; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); remain = len / 2; vmem16 = (u16 *)(par->info->screen_buffer + offset); @@ -153,8 +154,8 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) while (remain) { to_copy = min(tx_array_size, remain); - dev_dbg(par->info->device, " to_copy=%zu, remain=%zu\n", - to_copy, remain - to_copy); + dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n", + to_copy, remain - to_copy); for (i = 0; i < to_copy; i++) txbuf16[i] = cpu_to_be16(vmem16[i]); @@ -183,7 +184,7 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) int ret = 0; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); if (!par->txbuf.buf) { dev_err(par->info->device, "%s: txbuf.buf is NULL\n", __func__); @@ -197,8 +198,8 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len) while (remain) { to_copy = min(tx_array_size, remain); - dev_dbg(par->info->device, " to_copy=%zu, remain=%zu\n", - to_copy, remain - to_copy); + dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n", + to_copy, remain - to_copy); #ifdef __LITTLE_ENDIAN for (i = 0; i < to_copy; i += 2) { @@ -233,7 +234,7 @@ int fbtft_write_vmem16_bus16(struct fbtft_par *par, size_t offset, size_t len) u16 *vmem16; fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n", - __func__, offset, len); + __func__, offset, len); vmem16 = (u16 *)(par->info->screen_buffer + offset); diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 731e47149af8..a2df02d97a8e 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -137,8 +137,8 @@ static int fbtft_request_gpios(struct fbtft_par *par) flags = fbtft_request_gpios_match(par, gpio); if (flags != FBTFT_GPIO_NO_MATCH) { ret = devm_gpio_request_one(par->info->device, - gpio->gpio, flags, - par->info->device->driver->name); + gpio->gpio, flags, + par->info->device->driver->name); if (ret < 0) { dev_err(par->info->device, "%s: gpio_request_one('%s'=%d) failed with %d\n", @@ -249,8 +249,8 @@ static int fbtft_backlight_update_status(struct backlight_device *bd) bool polarity = par->polarity; fbtft_par_dbg(DEBUG_BACKLIGHT, par, - "%s: polarity=%d, power=%d, fb_blank=%d\n", - __func__, polarity, bd->props.power, bd->props.fb_blank); + "%s: polarity=%d, power=%d, fb_blank=%d\n", + __func__, polarity, bd->props.power, bd->props.fb_blank); if ((bd->props.power == FB_BLANK_UNBLANK) && (bd->props.fb_blank == FB_BLANK_UNBLANK)) @@ -372,7 +372,7 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line, if (start_line > par->info->var.yres - 1 || end_line > par->info->var.yres - 1) { dev_warn(par->info->device, - "%s: start_line=%u or end_line=%u is larger than max=%d. Shouldn't happen, will do full display update\n", + "%s: start_line=%u or end_line=%u is larger than max=%d. Shouldn't happen, will do full display update\n", __func__, start_line, end_line, par->info->var.yres - 1); start_line = 0; @@ -767,7 +767,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbops->fb_setcolreg = fbtft_fb_setcolreg; fbops->fb_blank = fbtft_fb_blank; - fbdefio->delay = HZ/fps; + fbdefio->delay = HZ / fps; fbdefio->deferred_io = fbtft_deferred_io; fb_deferred_io_init(info); @@ -817,8 +817,8 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, info->pseudo_palette = par->pseudo_palette; if (par->gamma.curves && gamma) { - if (fbtft_gamma_parse_str(par, - par->gamma.curves, gamma, strlen(gamma))) + if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma, + strlen(gamma))) goto alloc_fail; } @@ -1045,8 +1045,8 @@ static int fbtft_init_display_dt(struct fbtft_par *par) while (p && !(val & 0xFFFF0000)) { if (i > 63) { dev_err(par->info->device, - "%s: Maximum register values exceeded\n", - __func__); + "%s: Maximum register values exceeded\n", + __func__); return -EINVAL; } buf[i++] = val; @@ -1166,8 +1166,8 @@ int fbtft_init_display(struct fbtft_par *par) while (par->init_sequence[i] >= 0) { if (j > 63) { dev_err(par->info->device, - "%s: Maximum register values exceeded\n", - __func__); + "%s: Maximum register values exceeded\n", + __func__); return -EINVAL; } buf[j++] = par->init_sequence[i++]; @@ -1193,7 +1193,8 @@ int fbtft_init_display(struct fbtft_par *par) case -2: i++; fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "init: mdelay(%d)\n", par->init_sequence[i]); + "init: mdelay(%d)\n", + par->init_sequence[i]); mdelay(par->init_sequence[i++]); break; default: @@ -1225,8 +1226,8 @@ static int fbtft_verify_gpios(struct fbtft_par *par) fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); - if (pdata->display.buswidth != 9 && par->startbyte == 0 && - par->gpio.dc < 0) { + if (pdata->display.buswidth != 9 && par->startbyte == 0 && + par->gpio.dc < 0) { dev_err(par->info->device, "Missing info about 'dc' gpio. Aborting.\n"); return -EINVAL; @@ -1321,7 +1322,8 @@ static struct fbtft_platform_data *fbtft_probe_dt(struct device *dev) * Return: 0 if successful, negative if error */ int fbtft_probe_common(struct fbtft_display *display, - struct spi_device *sdev, struct platform_device *pdev) + struct spi_device *sdev, + struct platform_device *pdev) { struct device *dev; struct fb_info *info; @@ -1393,11 +1395,12 @@ int fbtft_probe_common(struct fbtft_display *display, par->spi->bits_per_word = 9; } else { dev_warn(&par->spi->dev, - "9-bit SPI not available, emulating using 8-bit.\n"); + "9-bit SPI not available, emulating using 8-bit.\n"); /* allocate buffer with room for dc bits */ par->extra = devm_kzalloc(par->info->device, - par->txbuf.len + (par->txbuf.len / 8) + 8, - GFP_KERNEL); + par->txbuf.len + + (par->txbuf.len / 8) + 8, + GFP_KERNEL); if (!par->extra) { ret = -ENOMEM; goto out_release; diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c index f4a591919f62..b5051d3d46a6 100644 --- a/drivers/staging/fbtft/fbtft-io.c +++ b/drivers/staging/fbtft/fbtft-io.c @@ -14,7 +14,7 @@ int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len) struct spi_message m; fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); if (!par->spi) { dev_err(par->info->device, @@ -47,7 +47,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) u64 val, dc, tmp; fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); if (!par->extra) { dev_err(par->info->device, "%s: error: par->extra is NULL\n", @@ -109,14 +109,15 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len) txbuf[0] = par->startbyte | 0x3; t.tx_buf = txbuf; fbtft_par_dbg_hex(DEBUG_READ, par, par->info->device, u8, - txbuf, len, "%s(len=%d) txbuf => ", __func__, len); + txbuf, len, "%s(len=%d) txbuf => ", + __func__, len); } spi_message_init(&m); spi_message_add_tail(&t, &m); ret = spi_sync(par->spi, &m); fbtft_par_dbg_hex(DEBUG_READ, par, par->info->device, u8, buf, len, - "%s(len=%d) buf <= ", __func__, len); + "%s(len=%d) buf <= ", __func__, len); return ret; } @@ -135,7 +136,7 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len--) { data = *(u8 *)buf; @@ -151,7 +152,7 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 8; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } @@ -185,7 +186,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len) { data = *(u16 *)buf; @@ -201,7 +202,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 16; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c index 712096659aa0..2a5c630dab87 100644 --- a/drivers/staging/fbtft/fbtft-sysfs.c +++ b/drivers/staging/fbtft/fbtft-sysfs.c @@ -126,7 +126,8 @@ static ssize_t store_gamma_curve(struct device *device, mutex_lock(&par->gamma.lock); memcpy(par->gamma.curves, tmp_curves, - par->gamma.num_curves * par->gamma.num_values * sizeof(tmp_curves[0])); + par->gamma.num_curves * par->gamma.num_values * + sizeof(tmp_curves[0])); mutex_unlock(&par->gamma.lock); return count; diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h index c7cb4a7896f4..798a8fe98e95 100644 --- a/drivers/staging/fbtft/fbtft.h +++ b/drivers/staging/fbtft/fbtft.h @@ -64,16 +64,16 @@ struct fbtft_ops { void (*write_register)(struct fbtft_par *par, int len, ...); void (*set_addr_win)(struct fbtft_par *par, - int xs, int ys, int xe, int ye); + int xs, int ys, int xe, int ye); void (*reset)(struct fbtft_par *par); void (*mkdirty)(struct fb_info *info, int from, int to); void (*update_display)(struct fbtft_par *par, - unsigned int start_line, unsigned int end_line); + unsigned int start_line, unsigned int end_line); int (*init_display)(struct fbtft_par *par); int (*blank)(struct fbtft_par *par, bool on); unsigned long (*request_gpios_match)(struct fbtft_par *par, - const struct fbtft_gpio *gpio); + const struct fbtft_gpio *gpio); int (*request_gpios)(struct fbtft_par *par); int (*verify_gpios)(struct fbtft_par *par); @@ -234,8 +234,8 @@ struct fbtft_par { #define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int)) -#define write_reg(par, ...) \ - par->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__) +#define write_reg(par, ...) \ + ((par)->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__)) /* fbtft-core.c */ int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc); @@ -404,8 +404,9 @@ do { \ #define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - fbtft_dbg_hex(dev, sizeof(type), buf, num * sizeof(type), format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + fbtft_dbg_hex(dev, sizeof(type), buf,\ + (num) * sizeof(type), format, ##arg); \ } while (0) #endif /* __LINUX_FBTFT_H */ diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index ec8477674b7d..50e97da993e7 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -21,12 +21,13 @@ static struct platform_device *p_device; static char *name; module_param(name, charp, 0000); -MODULE_PARM_DESC(name, "Devicename (required). name=list => list all supported devices."); +MODULE_PARM_DESC(name, + "Devicename (required). name=list => list all supported devices."); static unsigned int rotate; module_param(rotate, uint, 0000); MODULE_PARM_DESC(rotate, -"Angle to rotate display counter clockwise: 0, 90, 180, 270"); + "Angle to rotate display counter clockwise: 0, 90, 180, 270"); static unsigned int busnum; module_param(busnum, uint, 0000); @@ -47,7 +48,7 @@ MODULE_PARM_DESC(mode, "SPI mode (override device default)"); static char *gpios; module_param(gpios, charp, 0000); MODULE_PARM_DESC(gpios, -"List of gpios. Comma separated with the form: reset:23,dc:24 (when overriding the default, all gpios must be specified)"); + "List of gpios. Comma separated with the form: reset:23,dc:24 (when overriding the default, all gpios must be specified)"); static unsigned int fps; module_param(fps, uint, 0000); @@ -56,7 +57,7 @@ MODULE_PARM_DESC(fps, "Frames per second (override driver default)"); static char *gamma; module_param(gamma, charp, 0000); MODULE_PARM_DESC(gamma, -"String representation of Gamma Curve(s). Driver specific."); + "String representation of Gamma Curve(s). Driver specific."); static int txbuflen; module_param(txbuflen, int, 0000); @@ -65,7 +66,7 @@ MODULE_PARM_DESC(txbuflen, "txbuflen (override driver default)"); static int bgr = -1; module_param(bgr, int, 0000); MODULE_PARM_DESC(bgr, -"BGR bit (supported by some drivers)."); + "BGR bit (supported by some drivers)."); static unsigned int startbyte; module_param(startbyte, uint, 0000); @@ -95,12 +96,12 @@ MODULE_PARM_DESC(init, "Init sequence, used with the custom argument"); static unsigned long debug; module_param(debug, ulong, 0000); MODULE_PARM_DESC(debug, -"level: 0-7 (the remaining 29 bits is for advanced usage)"); + "level: 0-7 (the remaining 29 bits is for advanced usage)"); static unsigned int verbose = 3; module_param(verbose, uint, 0000); MODULE_PARM_DESC(verbose, -"0 silent, >0 show gpios, >1 show devices, >2 show devices before (default=3)"); + "0 silent, >0 show gpios, >1 show devices, >2 show devices before (default=3)"); struct fbtft_device_display { char *name; @@ -112,7 +113,7 @@ static void fbtft_device_pdev_release(struct device *dev); static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len); static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par, - int xs, int ys, int xe, int ye); + int xs, int ys, int xe, int ye); #define ADAFRUIT18_GAMMA \ "02 1c 07 12 37 32 29 2d 29 25 2B 39 00 01 03 10\n" \ @@ -261,6 +262,10 @@ static const s16 waveshare32b_init_sequence[] = { -3 }; +#define PIOLED_GAMMA "0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 " \ + "2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " \ + "3 3 3 4 4 4 4 4 4 4 4 4 4 4 4" + /* Supported displays in alphabetical order */ static struct fbtft_device_display displays[] = { { @@ -832,7 +837,6 @@ static struct fbtft_device_display displays[] = { } } }, { - .name = "piscreen", .spi = &(struct spi_board_info) { .modalias = "fb_ili9486", @@ -889,14 +893,7 @@ static struct fbtft_device_display displays[] = { { "dc", 25 }, {}, }, - .gamma = "0 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 2 " - "2 2 2 2 2 2 2 3 " - "3 3 3 3 3 3 3 3 " - "3 3 3 3 3 3 3 3 " - "3 3 3 4 4 4 4 4 " - "4 4 4 4 4 4 4" + .gamma = PIOLED_GAMMA } } }, { @@ -1223,14 +1220,14 @@ static struct fbtft_device_display displays[] = { .name = "", .id = 0, .dev = { - .release = fbtft_device_pdev_release, - .platform_data = &(struct fbtft_platform_data) { - .gpios = (const struct fbtft_gpio []) { - {}, + .release = fbtft_device_pdev_release, + .platform_data = &(struct fbtft_platform_data) { + .gpios = (const struct fbtft_gpio []) { + {}, + }, }, }, }, - }, } }; @@ -1243,7 +1240,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) #endif fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, - "%s(len=%d): ", __func__, len); + "%s(len=%d): ", __func__, len); while (len) { data = *(u16 *)buf; @@ -1259,7 +1256,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 16; i++) { if ((data & 1) != (prev_data & 1)) gpio_set_value(par->gpio.db[i], - data & 1); + data & 1); data >>= 1; prev_data >>= 1; } @@ -1285,7 +1282,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len) } static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par, - int xs, int ys, int xe, int ye) + int xs, int ys, int xe, int ye) { write_reg(par, 0x2A, 0, xs + 2, 0, xe + 2); write_reg(par, 0x2B, 0, ys + 1, 0, ye + 1); @@ -1476,7 +1473,7 @@ static int __init fbtft_device_init(void) size_t len; len = strlcpy(displays[i].spi->modalias, name, - SPI_NAME_SIZE); + SPI_NAME_SIZE); if (len >= SPI_NAME_SIZE) pr_warn("modalias (name) truncated to: %s\n", displays[i].spi->modalias); @@ -1582,7 +1579,6 @@ static void __exit fbtft_device_exit(void) if (p_device) platform_device_unregister(p_device); - } arch_initcall(fbtft_device_init); diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index f676c9b853f1..2af474469e7d 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -679,22 +679,27 @@ static int flexfb_probe_common(struct spi_device *sdev, if (par->spi->master->bits_per_word_mask & SPI_BPW_MASK(9)) { par->spi->bits_per_word = 9; - } else { - dev_warn(dev, - "9-bit SPI not available, emulating using 8-bit.\n"); - /* allocate buffer with room for dc bits */ - par->extra = devm_kzalloc(par->info->device, - par->txbuf.len + (par->txbuf.len / 8) + 8, - GFP_KERNEL); - if (!par->extra) { - ret = -ENOMEM; - goto out_release; - } - par->fbtftops.write = fbtft_write_spi_emulate_9; + break; } + + dev_warn(dev, + "9-bit SPI not available, emulating using 8-bit.\n"); + /* allocate buffer with room for dc bits */ + par->extra = devm_kzalloc(par->info->device, + par->txbuf.len + + (par->txbuf.len / 8) + 8, + GFP_KERNEL); + if (!par->extra) { + ret = -ENOMEM; + goto out_release; + } + par->fbtftops.write = fbtft_write_spi_emulate_9; + break; default: - dev_err(dev, "argument 'buswidth': %d is not supported with SPI.\n", buswidth); + dev_err(dev, + "argument 'buswidth': %d is not supported with SPI.\n", + buswidth); return -EINVAL; } } else { |