Lines Matching refs:cmd

74 void DwMipiDsi::DumpCmd(const MipiDsiCmd& cmd) {
76 zxlogf(ERROR, "\t\t\t\t VIC = 0x%x (%d)\n", cmd.virt_chn_id, cmd.virt_chn_id);
77 zxlogf(ERROR, "\t\t\t\t Data Type = 0x%x (%d)\n", cmd.dsi_data_type, cmd.dsi_data_type);
78 zxlogf(ERROR, "\t\t\t\t ACK = 0x%x (%d)\n", cmd.flags, cmd.flags);
79 zxlogf(ERROR, "\t\t\t\t Payload size = 0x%lx (%ld)\n", cmd.pld_size, cmd.pld_size);
82 for (size_t i = 0; i < cmd.pld_size; i++) {
83 zxlogf(ERROR, "0x%x, ", cmd.pld_data[i]);
99 // make sure cmd fifo is not full before writing into it
169 zx_status_t DwMipiDsi::GenWriteShort(const MipiDsiCmd& cmd) {
171 if ((cmd.pld_size > 2) ||
172 (cmd.pld_size > 0 && cmd.pld_data == NULL) ||
173 (cmd.dsi_data_type & MIPI_DSI_DT_GEN_SHORT_WRITE_0) != MIPI_DSI_DT_GEN_SHORT_WRITE_0) {
174 DISP_ERROR("Invalid Gen short cmd sent\n");
179 regVal |= GEN_HDR_DT(cmd.dsi_data_type);
180 regVal |= GEN_HDR_VC(cmd.virt_chn_id);
181 if (cmd.pld_size >= 1) {
182 regVal |= GEN_HDR_WC_LSB(cmd.pld_data[0]);
184 if (cmd.pld_size == 2) {
185 regVal |= GEN_HDR_WC_MSB(cmd.pld_data[1]);
191 zx_status_t DwMipiDsi::DcsWriteShort(const MipiDsiCmd& cmd) {
193 if ((cmd.pld_size > 1) ||
194 (cmd.pld_data == NULL) ||
195 (cmd.dsi_data_type & MIPI_DSI_DT_DCS_SHORT_WRITE_0) != MIPI_DSI_DT_DCS_SHORT_WRITE_0) {
201 regVal |= GEN_HDR_DT(cmd.dsi_data_type);
202 regVal |= GEN_HDR_VC(cmd.virt_chn_id);
203 regVal |= GEN_HDR_WC_LSB(cmd.pld_data[0]);
204 if (cmd.pld_size == 1) {
205 regVal |= GEN_HDR_WC_MSB(cmd.pld_data[1]);
213 zx_status_t DwMipiDsi::GenWriteLong(const MipiDsiCmd& cmd) {
217 ZX_DEBUG_ASSERT(cmd.pld_size < DWC_DEFAULT_MAX_PLD_FIFO_DEPTH);
218 size_t ts = cmd.pld_size; // initial transfer size
220 if (ts > 0 && cmd.pld_data == NULL) {
227 regVal = cmd.pld_data[pld_data_idx + 0] << 0 |
228 cmd.pld_data[pld_data_idx + 1] << 8 |
229 cmd.pld_data[pld_data_idx + 2] << 16 |
230 cmd.pld_data[pld_data_idx + 3] << 24;
241 regVal = cmd.pld_data[pld_data_idx++] << 0;
243 regVal |= cmd.pld_data[pld_data_idx++] << 8;
246 regVal |= cmd.pld_data[pld_data_idx++] << 16;
256 regVal |= GEN_HDR_DT(cmd.dsi_data_type);
257 regVal |= GEN_HDR_VC(cmd.virt_chn_id);
258 regVal |= GEN_HDR_WC_LSB(static_cast<uint32_t>(cmd.pld_size) & 0xFF);
259 regVal |= GEN_HDR_WC_MSB((cmd.pld_size & 0xFF00) >> 16);
264 zx_status_t DwMipiDsi::GenRead(const MipiDsiCmd& cmd) {
268 // valid cmd packet
269 if ((cmd.rsp_data == NULL) || (cmd.pld_size > 2) ||
270 (cmd.pld_size > 0 && cmd.pld_data == NULL)) {
276 if (cmd.flags & MIPI_DSI_CMD_FLAGS_SET_MAX) {
278 regVal |= GEN_HDR_VC(cmd.virt_chn_id);
280 regVal |= GEN_HDR_WC_LSB(static_cast<uint32_t>(cmd.rsp_size) & 0xFF);
281 regVal |= GEN_HDR_WC_MSB((static_cast<uint32_t>(cmd.rsp_size) >> 8) & 0xFF);
290 regVal |= GEN_HDR_DT(cmd.dsi_data_type);
291 regVal |= GEN_HDR_VC(cmd.virt_chn_id);
292 if (cmd.pld_size >= 1) {
293 regVal |= GEN_HDR_WC_LSB(cmd.pld_data[0]);
295 if (cmd.pld_size == 2) {
296 regVal |= GEN_HDR_WC_MSB(cmd.pld_data[1]);
315 size_t ts = cmd.rsp_size;
323 cmd.rsp_data[rsp_data_idx++] = static_cast<uint8_t>((data >> 0) & 0xFF);
324 cmd.rsp_data[rsp_data_idx++] = static_cast<uint8_t>((data >> 8) & 0xFF);
325 cmd.rsp_data[rsp_data_idx++] = static_cast<uint8_t>((data >> 16) & 0xFF);
326 cmd.rsp_data[rsp_data_idx++] = static_cast<uint8_t>((data >> 24) & 0xFF);
336 cmd.rsp_data[rsp_data_idx++] = (data >> 0) & 0xFF;
338 cmd.rsp_data[rsp_data_idx++] = (data >> 8) & 0xFF;
341 cmd.rsp_data[rsp_data_idx++] = (data >> 16) & 0xFF;
350 zx_status_t DwMipiDsi::SendCmd(const MipiDsiCmd& cmd) {
354 switch (cmd.dsi_data_type) {
358 status = GenWriteShort(cmd);
362 status = GenWriteLong(cmd);
367 status = GenRead(cmd);
371 status = DcsWriteShort(cmd);
375 DISP_ERROR("Unsupported/Invalid DSI Command type %d\n", cmd.dsi_data_type);
381 DumpCmd(cmd);
391 MipiDsiCmd cmd;
392 cmd.virt_chn_id = MIPI_DSI_VIRTUAL_CHAN_ID; // TODO(payamm): change name
393 cmd.pld_data = tbuf; // tbuf is allowed to be null
394 cmd.pld_size = tlen;
395 cmd.rsp_data = rbuf; // rbuf is allowed to be null if rlen is 0
396 cmd.rsp_size = rlen;
397 cmd.flags = 0;
398 cmd.dsi_data_type = MIPI_DSI_DT_UNKNOWN;
403 cmd.dsi_data_type = is_dcs ? MIPI_DSI_DT_DCS_READ_0 :
405 cmd.flags |= MIPI_DSI_CMD_FLAGS_ACK | MIPI_DSI_CMD_FLAGS_SET_MAX;
407 cmd.dsi_data_type = is_dcs ? MIPI_DSI_DT_DCS_SHORT_WRITE_0 :
417 cmd.dsi_data_type = MIPI_DSI_DT_GEN_SHORT_READ_1;
418 cmd.flags |= MIPI_DSI_CMD_FLAGS_ACK | MIPI_DSI_CMD_FLAGS_SET_MAX;
420 cmd.dsi_data_type = is_dcs ? MIPI_DSI_DT_DCS_SHORT_WRITE_1 :
430 cmd.flags |= MIPI_DSI_CMD_FLAGS_ACK | MIPI_DSI_CMD_FLAGS_SET_MAX;
432 cmd.dsi_data_type = MIPI_DSI_DT_GEN_SHORT_WRITE_2;
440 cmd.dsi_data_type = is_dcs ? MIPI_DSI_DT_DCS_LONG_WRITE :
447 return SendCmd(cmd);