Lines Matching refs:dbi
101 static bool mipi_dbi_command_is_read(struct mipi_dbi *dbi, u8 cmd)
105 if (!dbi->read_commands)
109 if (!dbi->read_commands[i])
111 if (cmd == dbi->read_commands[i])
120 * @dbi: MIPI DBI structure
129 int mipi_dbi_command_read(struct mipi_dbi *dbi, u8 cmd, u8 *val)
131 if (!dbi->read_commands)
134 if (!mipi_dbi_command_is_read(dbi, cmd))
137 return mipi_dbi_command_buf(dbi, cmd, val, 1);
143 * @dbi: MIPI DBI structure
151 int mipi_dbi_command_buf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len)
161 mutex_lock(&dbi->cmdlock);
162 ret = dbi->command(dbi, cmdbuf, data, len);
163 mutex_unlock(&dbi->cmdlock);
172 int mipi_dbi_command_stackbuf(struct mipi_dbi *dbi, u8 cmd, const u8 *data,
182 ret = mipi_dbi_command_buf(dbi, cmd, buf, len);
244 struct mipi_dbi *dbi = &dbidev->dbi;
251 mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xff,
253 mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xff,
264 struct mipi_dbi *dbi = &dbidev->dbi;
265 bool swap = dbi->swap_bytes;
280 if (!dbi->dc || !full || swap ||
293 ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, tr,
365 struct mipi_dbi *dbi = &dbidev->dbi;
375 mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START,
506 if (!dbidev->dbi.command)
583 * @dbi: MIPI DBI structure
587 void mipi_dbi_hw_reset(struct mipi_dbi *dbi)
589 if (!dbi->reset)
592 gpiod_set_value_cansleep(dbi->reset, 0);
594 gpiod_set_value_cansleep(dbi->reset, 1);
601 * @dbi: MIPI DBI structure
611 bool mipi_dbi_display_is_on(struct mipi_dbi *dbi)
615 if (mipi_dbi_command_read(dbi, MIPI_DCS_GET_POWER_MODE, &val))
634 struct mipi_dbi *dbi = &dbidev->dbi;
645 if (cond && mipi_dbi_display_is_on(dbi))
648 mipi_dbi_hw_reset(dbi);
649 ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
662 if (dbi->reset)
751 static int mipi_dbi_spi1e_transfer(struct mipi_dbi *dbi, int dc,
756 size_t chunk, max_chunk = dbi->tx_buf9_len;
757 struct spi_device *spi = dbi->spi;
759 .tx_buf = dbi->tx_buf9,
779 dst = dbi->tx_buf9;
799 dst = dbi->tx_buf9;
869 static int mipi_dbi_spi1_transfer(struct mipi_dbi *dbi, int dc,
873 struct spi_device *spi = dbi->spi;
885 return mipi_dbi_spi1e_transfer(dbi, dc, buf, len, bpw);
888 max_chunk = dbi->tx_buf9_len;
889 dst16 = dbi->tx_buf9;
932 static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd,
938 if (mipi_dbi_command_is_read(dbi, *cmd))
943 ret = mipi_dbi_spi1_transfer(dbi, 0, cmd, 1, 8);
947 return mipi_dbi_spi1_transfer(dbi, 1, parameters, num, bpw);
952 static int mipi_dbi_typec3_command_read(struct mipi_dbi *dbi, u8 *cmd,
955 struct spi_device *spi = dbi->spi;
992 gpiod_set_value_cansleep(dbi->dc, 0);
1016 static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd,
1019 struct spi_device *spi = dbi->spi;
1024 if (mipi_dbi_command_is_read(dbi, *cmd))
1025 return mipi_dbi_typec3_command_read(dbi, cmd, par, num);
1029 gpiod_set_value_cansleep(dbi->dc, 0);
1035 if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !dbi->swap_bytes)
1038 gpiod_set_value_cansleep(dbi->dc, 1);
1047 * @dbi: MIPI DBI structure to initialize
1066 int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
1090 dbi->spi = spi;
1091 dbi->read_commands = mipi_dbi_dcs_read_commands;
1094 dbi->command = mipi_dbi_typec3_command;
1095 dbi->dc = dc;
1097 dbi->swap_bytes = true;
1099 dbi->command = mipi_dbi_typec1_command;
1100 dbi->tx_buf9_len = SZ_16K;
1101 dbi->tx_buf9 = devm_kmalloc(dev, dbi->tx_buf9_len, GFP_KERNEL);
1102 if (!dbi->tx_buf9)
1106 mutex_init(&dbi->cmdlock);
1219 ret = mipi_dbi_command_buf(&dbidev->dbi, cmd, parameters, i);
1232 struct mipi_dbi *dbi = &dbidev->dbi;
1241 if (!mipi_dbi_command_is_read(dbi, cmd))
1261 ret = mipi_dbi_command_buf(dbi, cmd, val, len);
1304 if (dbidev->dbi.read_commands)