drivers/staging/fbtft/fb_ssd1351.c

Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fb_ssd1351.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/fbtft/fb_ssd1351.c
Extension
.c
Size
6449 bytes
Lines
241
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (i > 0 && curves[i] < 2) {
			dev_err(par->info->device,
				"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 : %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]);

	return 0;
}

static int blank(struct fbtft_par *par, bool on)
{
	fbtft_par_dbg(DEBUG_BLANK, par, "(%s=%s)\n",
		      __func__, str_true_false(on));
	if (on)
		write_reg(par, 0xAE);
	else
		write_reg(par, 0xAF);
	return 0;
}

static struct fbtft_display display = {
	.regwidth = 8,
	.width = WIDTH,
	.height = HEIGHT,
	.gamma_num = GAMMA_NUM,
	.gamma_len = GAMMA_LEN,
	.gamma = DEFAULT_GAMMA,
	.fbtftops = {
		.init_display = init_display,
		.set_addr_win = set_addr_win,
		.set_var = set_var,
		.set_gamma = set_gamma,
		.blank = blank,
	},
};

static int update_onboard_backlight(struct backlight_device *bd)
{
	struct fbtft_par *par = bl_get_data(bd);
	bool on;

	fbtft_par_dbg(DEBUG_BACKLIGHT, par, "%s: power=%d\n", __func__, bd->props.power);

	on = !backlight_is_blank(bd);
	/* Onboard backlight connected to GPIO0 on SSD1351, GPIO1 unused */
	write_reg(par, 0xB5, on ? 0x03 : 0x02);

	return 0;
}

static const struct backlight_ops bl_ops = {
	.update_status = update_onboard_backlight,
};

static void register_onboard_backlight(struct fbtft_par *par)
{
	struct backlight_device *bd;
	struct backlight_properties bl_props = { 0, };

	bl_props.type = BACKLIGHT_RAW;
	bl_props.power = BACKLIGHT_POWER_OFF;

Annotation

Implementation Notes